Another hint, which you'll also find sooner or later when following the
link I provided, is the Xray tool. It's great for investigating objects.
I went the other way around, I started writing macros in OpenOffice.org
Calc (then LibreOffice Calc, then Apache OpenOffice and now LibreOffice
Calc again) and now I'm also writing macros in Excel at work (I run 100 %
Linux at home so no Excel there). There are some similarities but the
differences are also huge. Some things are easier in Excel and some things
are easier in LibreOffice/Apache OpenOffice.
Here are some really basic examples about working vill cell values:
Option Explicit
Dim MyString As String, Col As Long, Row As Long
Row=3
Col=9
' You can refer to sheets and cells by names or position. the following two
lines can be equivalent:
MyString=ThisComponent.Sheets.getByName("Data").getCellByPosition(Col,Row).getString()
MyString=ThisComponent.Sheets.getByIndex(2).getCellRangeByName("J4").getString()
' The other way around:
ThisComponent.Sheets.getByName("Data").getCellByPosition(Col,Row).setString(MyString)
ThisComponent.Sheets.getByIndex(2).getCellRangeByName("J4").setString(MyString)
Also available are .setFormula(), .setValue(), getFormula() and getValue().
Of course you can make the lines shorted like these examples:
' Example 1
Dim Sheet As Object, Cell As Object
Sheet=ThisComponent.Sheets.getByName("Data")
Cell=Sheet.getCellByPosition(Col,Row)
MyString=Cell.getString()
' Example 2
Dim MyFormula As String
With ThisComponent.Sheets.getByName("Data")
MyString=.getCellByPosition(Col,Row).getString()
MyFormula=.getCellByPosition(Col,Row).getFormula()
End With
Kind regards
Johnny Rosenberg