Page 1 of 1
[Solved] Macro not available in Form for switchboard
Posted: Wed Feb 26, 2014 1:27 pm
by iqullc
Hello AOO
Following step by step instruction in the tutorial for standalone forms/switchboard.
One of my forms has 2 sub forms. The main form has a macro that clears content when the form is opened. When I tested the standalone form I got a message the Basic script could not be loaded.
I checked Events, When Loading...gives the appearance the script is there, but it is not. How do I get the script onto the standalone form, copying does not seem to be an option.
Thanks in advance
Stephanie
Re: Macro not available in standalone Form for switchboard
Posted: Wed Feb 26, 2014 4:53 pm
by MTP
The macro needs to be saved either in a general openoffice module (called "my macros" or "openoffice macros" in the window from Tools->Macros->Organize Macros->select language used) - and I think in the general modules macros have to be "activated" before they can be used by a specific document - or saved inside the module for the standalone form (this is most common, and I think easiest). I suspect the macro you need is saved in the *.odb form and hasn't been copied to the module for the standalone form. It doesn't do the form any good to have the name of the macro (what is shown in Events tab) if the text of the macro isn't available to it.
Re: Macro not available in standalone Form for switchboard
Posted: Wed Feb 26, 2014 8:07 pm
by iqullc
Thanks MTP as always I will give this a try and follow up.
It sounds like the macro will reside in two places...in the Standard folder under my database folder and as you suggest under general modules, will this cause a conflict at run time for the form?
BTW I see you have 4.0.1...I installed it and having considerable delays and lag times with everything. Have you experienced the same?
Re: Macro not available in standalone Form for switchboard
Posted: Wed Feb 26, 2014 8:35 pm
by MTP
I'm not very familiar with how macros behave when saved in one of the generic locations; all the ones I use I've saved inside the document that needs them (including standalone forms). I think there's a hierarchy of some sort and the program will choose the one lower in the hierarchy if there are multiple macros named the same.
I haven't had any problems with 4.0.1 and am not sure what would be causing your performance issues.
Re: Macro not available in standalone Form for switchboard
Posted: Wed Feb 26, 2014 8:40 pm
by RoryOF
Often delays in OpenOffice are caused by links to off-site (internet) locations. If possible, remove these.
Re: Macro not available in standalone Form for switchboard
Posted: Wed Feb 26, 2014 9:04 pm
by RPG
Hello
iqullc wrote:BTW I see you have 4.0.1...I installed it and having considerable delays and lag times with everything. Have you experienced the same?
You are not clear about when the delay happens?
When it happens when you change from the form in edit mode to working mode then it can be a problem of a bad designed from. This happens most of the time only when you have a lot of controls in your forms. Anchor all the controls to page.
Storing the macro's in different places is not a reasons for slowing down.
When you have bad designed macros then it can be a reason of slowing down. A bad designed macro is: a great number of loops and inside the loop SQL commands.
Romke
Re: Macro not available in standalone Form for switchboard
Posted: Wed Feb 26, 2014 9:28 pm
by iqullc
thanks to all the replies.
@RPG I posted the lag time issue earlier today...since installing 4.0.1 opening a form, editing, dragging/sizing controls any and everything has significant lag time, even typing and selecting. I built the database and forms using 4.0 none of these problems occurred.
@RoryOF, I do not understand about links to off-site (internet) locations, could you explain?
Re: Macro not available in standalone Form for switchboard
Posted: Wed Feb 26, 2014 9:38 pm
by RoryOF
If an OpenOffice file contains links to an Internet site - as for example to download a picture, but there are other purposes - It is said that it checks the valdity of each link on opening. Should a link not be available, or be slow, it pauses, waiting for that link to verify.
Re: Macro not available in standalone Form for switchboard
Posted: Wed Feb 26, 2014 10:07 pm
by RPG
Hello
When it works good in OOo 4.0.0 and not in OOo 4.0.1 then I have no idea. You can try to renew the user profile and try if this helps.
Maybe this
[Tutorial] The OOo user profile can help you. With unkown problems I try real often a new user profile. I rename only the directory. First close OOo complete also the quickstarter.
Romke
Re: Macro not available in standalone Form for switchboard
Posted: Thu Feb 27, 2014 3:22 am
by DACM
MTP wrote:The macro needs to be saved either in a general openoffice module (called "my macros" or "openoffice macros") - or - saved inside the module for the standalone form (this is most common, and I think easiest).
Some additional information:
You can save macros within the document including Base
.odb, Calc
.ods, and Writer
.odt -
or - in the global '
My Macros' location. The '
OpenOffice/LibreOffice Macros' location is read-only. Each location has its own advantages and disadvantages. 'My Macros' is great for universal libraries and extensions due to the application-wide scope. But macros stored within individual documents are more portable since they work across *Office installations and computers. Since portability is often a consideration,
the preferred location for macros used by standalone forms is the document itself (.odt). And keep in mind that portability is a factor even when when using a cloud folder for non-concurrent access (Dropbox, Google Drive, etc.), just as it is with
USB sneakernet.
Either way, you'll need to modify any reference to '
ThisDatabaseDocument' since that context is lost when exporting macros from a Base .odb file. In most cases '
ThisComponent' will serve as an apt replacement.
- For instance, if you want to open another standalone form (.odt) from a push button, the code for a Form embedded within the Base .odb file is no longer applicable:
Open Form macro stored within Base document (.odb):
Code: Select all
Sub OpenAddressForm 'Button > Event > Execute action
ThisDatabaseDocument.FormDocuments.GetByIndex(0).open() '.GetByName("<form name here>") may be easier to troubleshoot
Wait 100 'required on slower CPUs
ThisDatabaseDocument.FormDocuments.GetByIndex(0).Component.Drawpage.Forms.GetByIndex(0).moveToInsertRow
End Sub
Open Form macro stored within standalone Writer Form (.odt) using Shell:
Code: Select all
Sub OpenAddressForm 'Button > Event > Execute action
sPath = Left(ThisComponent.Location, Len(ThisComponent.Location) - Len(ThisComponent.Title))
sForm = ConvertToURL(sPath & "New Address.odt") 'example includes spaces
sWriter = ConvertToURL(CurDir & "\") & "swriter.exe" 'Windows exe
Shell (sWriter,,sForm)
End Sub
But I do want to emphasize that the push-button Switchboard outlined in the referenced tutorial is a macro-free solution.
...
Re: Macro not available in standalone Form for switchboard
Posted: Fri Feb 28, 2014 7:38 pm
by iqullc
Thanks to all, contemplating...

Re: Macro not available in standalone Form for switchboard
Posted: Sat Mar 08, 2014 3:15 pm
by iqullc
I opted to load the macro in the standard folder of the form that calls it. thanks!!! it works.

Re: [Solved] Macro not available in Form for switchboard
Posted: Mon Sep 22, 2014 3:35 pm
by rtochip
Hello,
Working with standalone files "first_file.odt" and "second_file.odt".
I was able to open the main form in "second_file.odt" from the main form of "first_file.odt".
Now, "ThisComponent.Drawpage.Forms(0) refers to the main form of the "first_file.odt" even when main form of "second_file.odt" is displayed.
How do we refer to the main form of "second_file.odt" programatically?
(i.e. it has field itemid and would like to assign it some some value.)
Tried
sPath = Left(ThisComponent.Location, Len(ThisComponent.Location) - Len(ThisComponent.Title))
myForm = ConvertToURL(sPath & "second_file.odt")
ThisComponent.Drawpage.Forms(myForm) still refers to the first_file.odt
Thanks