[Solved] Get String from cell to String of text

Creating a macro - Writing a Script - Using the API
Post Reply
Nelomf
Posts: 22
Joined: Wed Nov 06, 2019 4:29 pm

[Solved] Get String from cell to String of text

Post 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
Last edited by Nelomf on Mon Apr 19, 2021 2:01 pm, edited 1 time in total.
Openoffice 4, Windows 7
User avatar
robleyd
Moderator
Posts: 4424
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Get String from cell to String of text

Post by robleyd »

Does oCell.string not do what you want? See viewtopic.php?f=20&t=7915
Cheers
David
Apache OpenOffice 420m2(Build:9821) - Slackware 15 - 64 bit
LibreOffice 6.4.6.2 (SlackBuild for 6.4.6 by Eric Hameleers) - Slackware 15 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
Nelomf
Posts: 22
Joined: Wed Nov 06, 2019 4:29 pm

Re: Get String from cell to String of text

Post by Nelomf »

robleyd wrote:Does oCell.string not do what you want? See viewtopic.php?f=20&t=7915
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
Last edited by Nelomf on Mon Apr 19, 2021 12:35 pm, edited 1 time in total.
Openoffice 4, Windows 7
User avatar
robleyd
Moderator
Posts: 4424
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Get String from cell to String of text

Post by robleyd »

How are you creating the subject? I would get the string, then build the subject including the string variable.
Cheers
David
Apache OpenOffice 420m2(Build:9821) - Slackware 15 - 64 bit
LibreOffice 6.4.6.2 (SlackBuild for 6.4.6 by Eric Hameleers) - Slackware 15 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
Nelomf
Posts: 22
Joined: Wed Nov 06, 2019 4:29 pm

Re: Get String from cell to String of text

Post 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
Openoffice 4, Windows 7
User avatar
robleyd
Moderator
Posts: 4424
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Get String from cell to String of text

Post 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.
Cheers
David
Apache OpenOffice 420m2(Build:9821) - Slackware 15 - 64 bit
LibreOffice 6.4.6.2 (SlackBuild for 6.4.6 by Eric Hameleers) - Slackware 15 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
Nelomf
Posts: 22
Joined: Wed Nov 06, 2019 4:29 pm

Re: Get String from cell to String of text

Post by Nelomf »

Hello

Using the oCell.string result fine.

Thanks
Openoffice 4, Windows 7
Post Reply