I too am getting to grips with OpenOffice.org BASIC.

The best book that I have is:
Michael Koch, Special Edition Using StarOffice 6.0 published by Que,
ISBN 0-7897-2833-8.

I purchased it through Amazon.

It contains just under 100 pages about StarOffice BASIC, unfortunately a
lot of that is about programming in BASIC e.g "Using Condition
Expressions".

I have found the SDK essential for getting to grips with the underlying
model but I have, at times, found it difficult to find what I am looking
for.  E.g. I can find no reference to the Gallery.

I have not found the macro recorder to be particularly useful for
learning OOo BASIC.  The following is a recording of typing "Hello
World" into a text document:

sub HelloWorld
rem
----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem
----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem
----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Text"
args1(0).Value = "Hello World"

dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args1())


end sub

=================================================
Now for a hand coded version which inserts "Hello World" at each
selection (You can have multiple selections in OOo Writer documents).

Option Explicit

const UnoStub = "com.sun.star"
const UnoDesktop = UnoStub & ".frame.Desktop"
const UnoText = UnoStub & ".text"
const unoTextDocument = unoText & ".TextDocument"

Sub HelloWorld
Dim oDesktop as object, oDoc as object, oSelections as object
Dim iCSP as integer

oDesktop = createUnoService(UnoDesktop)
oDoc=oDesktop.getCurrentComponent()

if not oDoc.supportsService(UnoTextDocument) then
        Msgbox ("Not a text document", 0+16, "Error") '16 = stop icon
        exit sub
end if

oSelections = oDoc.CurrentSelection
for iCSP = 0 to oSelections.count -1
        oSelections(iCSP).String = "Hello World"
next icsp

End Sub

==================================================


I have found the following useful:
        msgbox oVar.dbg_methods()
        msgbox oVar.dbg_properties()
        msgbox oVar.dbg_SupportedInterfaces

for finding out what methods, properties and interfaces an object, oVAR,
supports/has.


I have written a number of OpenOffice.org macros and if I can be of
assistance with particular macros / problems then ask - I may be able to
help.

Thanks, Ian Laurenson


Reply via email to