Please point me to Calc Basic API tutorials...

Creating a macro - Writing a Script - Using the API

Please point me to Calc Basic API tutorials...

Postby Motdepasse » Wed Feb 20, 2008 2:03 am

Welcome beginner. Please answer all of the questions below which may provide information necessary to answer your question.
-----------------------------------------------------------------------------------------------------------
Which version of OpenOffice.org are you using? 2.3.1
What Operating System (version) are you using? Windows 2000 w/most recent service packs etc.
What is your question or comment?
I desperately need help with using the basic API for Calc. I've probably had to many years using VBA with Excel as nothing in the OpenOffice documentation makes any sense to me. Neither StarOfficeBasicGuide nor StarOfficeBasicTutorial are helpful. The tutorials seem to be just code fragments with key pieces of code missing. As an example the Guide has the following code fragment but it is not clear to me form the discussion in the document what statement or statements are missing as the code will not execute as written.

Dim Sheets As Object
Dim SheetNames
Dim I As Integer
Sheets = Spreadsheet.Sheets
SheetNames = Sheets.getElementNames
For I=LBound(SheetNames) To UBound(SheetNames)
MsgBox SheetNames(I)
Next I

I've searched for OpenOffice Calc API tutorials at the beginner level but havn't found anything that helps.

Thanks for any help.
Motdepasse
 
Posts: 3
Joined: Wed Feb 20, 2008 1:12 am

Re: Please point me to Calc Basic API tutorials...

Postby kingfisher » Wed Feb 20, 2008 3:36 am

You would be helped, I believe, by Andrew Pitonyak's macro document, the Xray tool and the SDK. You will find a collection of relevant links on a wiki page. You will find the SDK on OO mirrors and the Xray tool through ooomacros.org.
Apache OpenOffice 4.1.2 (64 bit) on PCLinuxOS
User avatar
kingfisher
Volunteer
 
Posts: 2111
Joined: Tue Nov 20, 2007 10:53 am

Re: Please point me to Calc Basic API tutorials...

Postby Motdepasse » Wed Feb 20, 2008 5:27 pm

kingfisher wrote:You would be helped, I believe, by Andrew Pitonyak's macro document, the Xray tool and the SDK. You will find a collection of relevant links on a wiki page. You will find the SDK on OO mirrors and the Xray tool through ooomacros.org.


Thanks for the wiki tip; I'll give it a try. I've looked through a lot of the wiki stuff already but had given up after finding little of value, perhaps Pitonyak is the key to my understanding.
Motdepasse
 
Posts: 3
Joined: Wed Feb 20, 2008 1:12 am

Re: Please point me to Calc Basic API tutorials...

Postby Motdepasse » Wed Feb 20, 2008 7:08 pm

After a little further searching I found a complete working example on how to get access to worksheets from a "Basic" macro. By adding the two lines indicated below everything works as expected. This change also gives access to all the cells on all the sheets.

It is such a simple but important addition to the code that I'm at a loss to understand why it was not included in the original fragment. The entire StarOfficeBasicGuide.pdf file that listed the fragment did not even include the entry for "ThisComponent"!

Dim Sheets As Object
Dim SheetNames
Dim I As Integer

'**************************************
Dim Spreadsheet as object
Spreadsheet = ThisComponent
'**************************************

Sheets = Spreadsheet.Sheets
SheetNames = Sheets.getElementNames
For I=LBound(SheetNames) To UBound(SheetNames)
MsgBox SheetNames(I)
Next I

 Edit: Hagar: removed the first post quoted, no need of it. 
Motdepasse
 
Posts: 3
Joined: Wed Feb 20, 2008 1:12 am

Re: Please point me to Calc Basic API tutorials...

Postby Hagar Delest » Wed Feb 20, 2008 10:02 pm

Moved to the Macros forum (there is a link to the Basic guide top of page).

Thanks to add '[Solved]' in your first post title (edit button) if your issue has been fixed.
AOO 4.1.5 on Xubuntu 18.04 and on Windows 7 (with winPenPack port).
User avatar
Hagar Delest
Moderator
 
Posts: 28114
Joined: Sun Oct 07, 2007 9:07 pm
Location: France


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 11 guests