Don Daugherty wrote:
Question 1:
How should I change the following macro so it that successfully
accesses a function and a subroutine in a different library?
If I access a subroutine, function, or variable, the macro interpreter
starts looking for the item that you referenced. You refer specifically
to a subroutine / function, so I will address that.
Subroutines and functions live in modules.
Modules live in libraries.
Libraries live in library containers. Examples of a library container is
a Write document, a Calc document, and OpenOffice.org.
Assume that you run a macro and the macro calls a subroutine called
"x1". The macro interpreter looks for x1 as follows:
* Current module.
* Other module in the current library.
* Other loaded library in the current library container (this is a guess).
* Other loaded library in either my macros, or openoffice.org macros.
There are a few things to notice. First, I stated that it only checks
loaded libraries. If you want to find a macro in another library, then
you must load that library. For example:
GlobalScope.BasicLibraries.LoadLibrary("Tools")
Now, I can call any macro in the Tools library. The other thing to
notice, is that I do not state that it will search for a library
contained in a different document. In your example, my guess is that the
library is named "Calc" and the module is named "CellOps". As such, I
would use
GlobalScope.BasicLibraries.LoadLibrary("Calc")
Call SelectAddr( SheetName$, Addr$ )
You only need to load a library once until you restart OOo.
It's not clear to me that my "path" is correct or that my use of
square brackets is done in a way the solves the problem of spaces in
the "My Macros & Dialogs" portion of the "path."
sub Main
rem
----------------------------------------------------------------------
rem define variables
Dim SheetName$, Addr$
rem get sheet name
SheetName$ = [soffice.My Macros & Dialogs.Calc.CellOps.Sheetname]
print SheetName$
' goto address appropriate to sheet -- default= A1 (0,0)
Addr$ = "A1"
If Sheet$="Fund Ratings" Then
Addr$ = "E9"
EndIf
Call [soffice.My Macros & Dialogs.Calc.CellOps.SelectAddr(
SheetName$, Addr$ )]
end sub
Question 2:
Where in the macro library structure should a Basic macro-function be
located in order for it to be used directly in a spreadsheet cell, ala
the Wahoo function in Andrew Pitonak's book "OpenOffice.org Macros
Explained", p. 368?
I typically store these in a library that I know will already be open,
the Standard library of the Calc document. Sometimes, especially if the
macro is long, I store a stub in the standard library and place the main
macro in a different library. I then load the primary library from the stub.
Question 3:
Is there a different list that I should have submitted the above
questions to? I'm sure that many, many OOo users have no interest in
such matters.
For API specific questions, you find more macro people hanging out in
[email protected].
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info: http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]