Calling a macro from another macro
Posted: Wed Jan 21, 2009 9:28 am
Somebody PLEASE help
I am using OOo 3.0.0 Base. I am trying to call a macro from another macro in another library. I keep getting an error that says "Basic Runtime Error. Variable not defined." I have spent weeks trying to find out how to make this work and have become extremely frustrated. I can't find any documentation or posts that have helped. Either they show a snippet of code without any context or they are for earlier versions of OOo that don't seem to apply anymore.
I did find a lengthy listing of code that uses executeDispatch() but it didn't make much sense and I figured there has to be a better way. The OOo help says you can execute code a macro by using the fully qualified macro name Library.Module.Macro() but that didn't work either, even after loading the library. Can somebody please help me find out what I need to do to make this work.
Here are the details of my application:
I currently have two forms: PartsEntry and ProjectsEntry. For the PartsEntry form I have a library called partsEntryLib and it has a module called partsEntryHandling. For the ProjectsEntry form I have a library called projectsEntryLib and it has a module called projectsEntryLib. On the ProjectsEntry form I have a button that executes ProjectsEntryLib.ProjectsEntryHandling.EditPart(). I will show the code for this macro below. (It does call an additional macro "startForm()" which loads and shows the PartsEntry form. I don't think it is necessary to show that code.) I will also probably make the code more concise but I have a lot of variables so I can watch what is going on. The macro does fine until the last line where I try to actually execute the other macro.
REM *** EDIT PART ***
sub editPart
dim componentForm as object
dim control as object
dim partsEntryForm as object
dim libraries as object
dim library as object
dim module as object
if isNull(projectsForm) then
init
end if
componentForm = projectsForm.getByName("componentDetails")
control = componentForm.Columns.getByName("partId")
partsEntryForm = startForm("PartsEntry") 'this starts and shows the PartsEntry form
libraries = partsEntryForm.BasicLibraries
library = libraries.getByName("partsEntryLib")
if not libraries.isLibraryLoaded("partsEntryLib") then
libraries.loadLibrary("partsEntryLib")
end if
partsEntryLib.partsEntryHandling.testRun 'this is where it fails
'partsEntryHandling.testRun 'this doesn't work either
'module = library.getByName("PartsHandling") 'this fails, though I can do a hasByName()
'partsEntryForm.ProjectHandling.queryPart(control,3)
end sub
I would really appreciate any help.
Thanks,
Justin
I am using OOo 3.0.0 Base. I am trying to call a macro from another macro in another library. I keep getting an error that says "Basic Runtime Error. Variable not defined." I have spent weeks trying to find out how to make this work and have become extremely frustrated. I can't find any documentation or posts that have helped. Either they show a snippet of code without any context or they are for earlier versions of OOo that don't seem to apply anymore.
I did find a lengthy listing of code that uses executeDispatch() but it didn't make much sense and I figured there has to be a better way. The OOo help says you can execute code a macro by using the fully qualified macro name Library.Module.Macro() but that didn't work either, even after loading the library. Can somebody please help me find out what I need to do to make this work.
Here are the details of my application:
I currently have two forms: PartsEntry and ProjectsEntry. For the PartsEntry form I have a library called partsEntryLib and it has a module called partsEntryHandling. For the ProjectsEntry form I have a library called projectsEntryLib and it has a module called projectsEntryLib. On the ProjectsEntry form I have a button that executes ProjectsEntryLib.ProjectsEntryHandling.EditPart(). I will show the code for this macro below. (It does call an additional macro "startForm()" which loads and shows the PartsEntry form. I don't think it is necessary to show that code.) I will also probably make the code more concise but I have a lot of variables so I can watch what is going on. The macro does fine until the last line where I try to actually execute the other macro.
REM *** EDIT PART ***
sub editPart
dim componentForm as object
dim control as object
dim partsEntryForm as object
dim libraries as object
dim library as object
dim module as object
if isNull(projectsForm) then
init
end if
componentForm = projectsForm.getByName("componentDetails")
control = componentForm.Columns.getByName("partId")
partsEntryForm = startForm("PartsEntry") 'this starts and shows the PartsEntry form
libraries = partsEntryForm.BasicLibraries
library = libraries.getByName("partsEntryLib")
if not libraries.isLibraryLoaded("partsEntryLib") then
libraries.loadLibrary("partsEntryLib")
end if
partsEntryLib.partsEntryHandling.testRun 'this is where it fails
'partsEntryHandling.testRun 'this doesn't work either
'module = library.getByName("PartsHandling") 'this fails, though I can do a hasByName()
'partsEntryForm.ProjectHandling.queryPart(control,3)
end sub
I would really appreciate any help.
Thanks,
Justin