[Solved] Get String from cell to String of text

Creating a macro - Writing a Script - Using the API

[Solved] Get String from cell to String of text

Postby Nelomf » Mon Apr 19, 2021 11:23 am

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
Nelomf
 
Posts: 22
Joined: Wed Nov 06, 2019 4:29 pm

Re: Get String from cell to String of text

Postby robleyd » Mon Apr 19, 2021 11:44 am

Does oCell.string not do what you want? See viewtopic.php?f=20&t=7915
Cheers
David
Apache OpenOffice 420m2(Build:9821) - Slackware 14.2 - 64 bit
LibreOffice 6.4.6.2 (SlackBuild for 6.4.6 by Eric Hameleers) - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
robleyd
Moderator
 
Posts: 4114
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Get String from cell to String of text

Postby Nelomf » Mon Apr 19, 2021 12:16 pm

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
Nelomf
 
Posts: 22
Joined: Wed Nov 06, 2019 4:29 pm

Re: Get String from cell to String of text

Postby robleyd » Mon Apr 19, 2021 12:34 pm

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 14.2 - 64 bit
LibreOffice 6.4.6.2 (SlackBuild for 6.4.6 by Eric Hameleers) - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
robleyd
Moderator
 
Posts: 4114
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Get String from cell to String of text

Postby Nelomf » Mon Apr 19, 2021 1:02 pm

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
Nelomf
 
Posts: 22
Joined: Wed Nov 06, 2019 4:29 pm

Re: Get String from cell to String of text

Postby robleyd » Mon Apr 19, 2021 1:19 pm

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   Expand viewCollapse view
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 14.2 - 64 bit
LibreOffice 6.4.6.2 (SlackBuild for 6.4.6 by Eric Hameleers) - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
robleyd
Moderator
 
Posts: 4114
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Get String from cell to String of text

Postby Nelomf » Mon Apr 19, 2021 1:51 pm

Hello

Using the oCell.string result fine.

Thanks
Openoffice 4, Windows 7
Nelomf
 
Posts: 22
Joined: Wed Nov 06, 2019 4:29 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 11 guests