[Solved] Writing Strings to Cells

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Drawmack
Posts: 3
Joined: Fri Apr 26, 2019 12:22 am

[Solved] Writing Strings to Cells

Post by Drawmack »

HI All,

I have the following code:

Code: Select all

	For i = (OutFirstRow + 11) to OutFirstRow step -1
		j = i - OutFirstRow
		k = (j- inKeyPos) Mod 11
		If (k < 0) Then
			k = 12 + k
		End If
		OutSheet.getCellByPosition(OutCapoCol,i).Value = k 'This call works
		OutSheet.getCellByPosition(OutPlayedCol,i).Value = keys(k) 'This call writes zero to the cells
	Next i
I have used the debugger to confirm that all the variables are set properly.
The output goes to the correct cells.
But, the output into the cell that should contain an entry from the keys array only contains zero
However, when I add a line that says MsgBox keys(k) that says the right key.
How can I get the string into the cell?
Last edited by robleyd on Fri Apr 26, 2019 2:14 pm, edited 2 times in total.
Reason: Add green tick
OpenOffice 4 on Windows 10
JeJe
Volunteer
Posts: 2781
Joined: Wed Mar 09, 2016 2:40 pm

Re: Writing Strings to Cells

Post by JeJe »

if keys(k) is a string value then you need to use .string = instead of .value =
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Drawmack
Posts: 3
Joined: Fri Apr 26, 2019 12:22 am

Re: Writing Strings to Cells

Post by Drawmack »

So you're saying that:

This line

Code: Select all

OutSheet.getCellByPosition(OutPlayedCol,i).Value = keys(k)
should be

Code: Select all

OutSheet.getCellByPosition(OutPlayedCol,i).string = keys(k)
?
OpenOffice 4 on Windows 10
JeJe
Volunteer
Posts: 2781
Joined: Wed Mar 09, 2016 2:40 pm

Re: Writing Strings to Cells

Post by JeJe »

Yes
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Zizi64
Volunteer
Posts: 11360
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Writing Strings to Cells

Post by Zizi64 »

...because the numeric value of a text equals zero in the spreadsheet applications...
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Drawmack
Posts: 3
Joined: Fri Apr 26, 2019 12:22 am

Re: Writing Strings to Cells

Post by Drawmack »

Thanks, that last post was very helpful.
OpenOffice 4 on Windows 10
Post Reply