Page 1 of 1
[Solved] Get String from cell to String of text
Posted: Mon Apr 19, 2021 11:23 am
by Nelomf
Hello
I have a calc book that sends a email.
The procedure is ready and the email goes out with recipient, subject and body already working.
But i want to include the String of a cell in the subject and i donĀ“t know how?
The subject is like this
"Envio folha encomendas"&" "&"de"&xxxxxxxx&" "&"enviada em"&" "&Day(basDate)&"/"&Month(basDate)&"/"&Year(basDate)
I want to place the string of the cell in the xxxxxx position
By the way the cell is this
Dim oSheet : oSheet = ThisComponent.Sheets.getByIndex(1)
Dim oCell : oCell = oSheet.getCellByPosition(1,0)
Many thanks
Manuel
Re: Get String from cell to String of text
Posted: Mon Apr 19, 2021 11:44 am
by robleyd
Does oCell.string not do what you want? See
viewtopic.php?f=20&t=7915
Re: Get String from cell to String of text
Posted: Mon Apr 19, 2021 12:16 pm
by Nelomf
I have tried
dim bares as text
xSheet = ThisComponent.Sheets(1)
oCell = xSheet.getCellByPosition(1,0)
bares = oCell.string
But when i use the string in the subject text
eSubject = "Envio folha encomendas"&" "&"de"&Bares&" "&"enviada em"&" "&Day(basDate)&"/"&Month(basDate)&"/"&Year(basDate)
Gives me a syntax error
Thanks
Re: Get String from cell to String of text
Posted: Mon Apr 19, 2021 12:34 pm
by robleyd
How are you creating the subject? I would get the string, then build the subject including the string variable.
Re: Get String from cell to String of text
Posted: Mon Apr 19, 2021 1:02 pm
by Nelomf
I have tried
dim bares as text
xSheet = ThisComponent.Sheets(1)
oCell = xSheet.getCellByPosition(1,0)
bares = oCell.string
But when i use the string in the subject text
eSubject = "Envio folha encomendas"&" "&"de"&Bares&" "&"enviada em"&" "&Day(basDate)&"/"&Month(basDate)&"/"&Year(basDate)
Gives me a syntax error
Thanks
Re: Get String from cell to String of text
Posted: Mon Apr 19, 2021 1:19 pm
by robleyd
Would help if you told what the syntax error was. But for a guess:
bares = oCell.string
eSubject = "Envio folha encomendas"&" " & "de" & Bares &" "&"
enviada em"&" "& Day(basDate)&"/" &Month(basDate) &"/" &Year(basDate)
Note that one variable name starts with upper case and the other with lower case.
I suspect you could also use
Code: Select all
eSubject = "Envio folha encomendas"&" " & "de" & oCell.string &" "&"
enviada em"&" "& Day(basDate)&"/" &Month(basDate) &"/" &Year(basDate)
You may also want a space after
de to separate it from the cell value you are including.
Re: Get String from cell to String of text
Posted: Mon Apr 19, 2021 1:51 pm
by Nelomf
Hello
Using the oCell.string result fine.
Thanks