I am totally new to OpenOffice macros, but have some experience with Excel VBA. What is the OpenOffice macro equivalent of this VBA statement to read the contents of a spreadsheet cell named "ABC"?
x = Range("ABC")
Also, what is the equivalent of this statement to read the contents of cell 1,1?
x = Cells(1,1)
Thanks for helping newbie!
Calc macro equivalent of VBA Range("...")
-
polczynskim
- Posts: 1
- Joined: Wed Jul 01, 2015 1:31 pm
Calc macro equivalent of VBA Range("...")
Apache OpenOffice 4.1.1 - Windows 8
Re: Calc macro equivalent of VBA Range("...")
To answer your two specific questions
There is a lot of good macro information at http://www.pitonyak.org/oo.php. There are also object inspectors call XRay and MRI, and you should get one of them if you want to write macros.
Code: Select all
oSheet = ThisComponent.Sheets.getByName("Sheet1")
x= oSheet.getCellRangeByName("ABC")
y= oSheet.getCellByPosition(Column, Row)OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Calc macro equivalent of VBA Range("...")
The NAMED cell(range) and the Absolut name of a cell is not equivalent. For example: $A$1 is an absolut name, but "ABC" is an user defined name of a specific cell.What is the OpenOffice macro equivalent of this VBA statement to read the contents of a spreadsheet cell named "ABC"?
Code: Select all
oDoc = ThisComponent ' get the actual document object
oRange = oDoc.NamedRanges.getByName("ABC") ' get a global named range object from the document
oCell = oRange.ReferredCells.getCellByPosition(0,0) ' get the top-left cell object from the named range
floatMyValue = oCell.Value
'stringMyString = oCell.String
'stringMyFormula = oCell.Formula
'stringMyFormulaLocal = oCell.FormulaLocal
Tibor Kovacs, Hungary; LO7.5.8/25.8.5.2 /Win7-10-11 x64Prof.
PortableApps: LO3.3.0-25.8.5.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.
PortableApps: LO3.3.0-25.8.5.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.