[Solved] Placing a value in a cell

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
AccessShell
Posts: 47
Joined: Tue Apr 05, 2022 2:17 am

[Solved] Placing a value in a cell

Post by AccessShell »

From a VB6 program I have successfully placed a string in a cell as follows

Code: Select all

strtest = "Dumb String"
    oSheet.getCellRangeByName("B1").String = strtest
This works fine. However, I need to place other types in cells, such as Date, Currency, integers, just to name a few.
For all these other data types, I get an error "Object doesn't support this property or method"

If I use .string when I have currency, the data in Calc does not perform as Currency and I can't place a formula in other cells to add up all these cells.

Any help would be appreciated.
Thanks
Last edited by AccessShell on Fri Apr 15, 2022 4:15 pm, edited 1 time in total.
LibreOffice 7.3.3.2 (x64) on Windows 10 Home
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Placing a value in a cell

Post by Zizi64 »

The Calc uses three types only:
- pure string (with some format properties)
- numeric values (the boolean values, the integers, the double precision numbers, the date-time values, the currency values)
- formula (what is a string really, but it will be interpreted and evaluated by the Calc).
I need to place other types in cells, such as Date, Currency, integers,
These are all numeric type values - with different format parameters. You can set the value:

Code: Select all

valtest = 3.14
    oSheet.getCellRangeByName("B1").Value = valtest
But you must set the format properties too, by applying a Cell style orby direct formatting method.

The third type is the Formula.

Code: Select all

strtest = "=A1*2+3.14"
    oSheet.getCellRangeByName("B1").Formula = strtest
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.
User avatar
AccessShell
Posts: 47
Joined: Tue Apr 05, 2022 2:17 am

Re: Placing a value in a cell

Post by AccessShell »

Thank you. It works just fine.
LibreOffice 7.3.3.2 (x64) on Windows 10 Home
Post Reply