Apache OpenOffice (AOO) Bugzilla – Issue 87741
Macros not accessible in form opened programmatically (without opening the database document) - approved
Last modified: 2009-07-19 19:18:56 UTC
I created a form in a Base document (.odb). I also created a couple of Basic macros in this form and assigned them to some buttons. I created a button in other documents (Calc and Writer docs) with a macro assigned that opens directly the form contained in the Base file. With OOo version 2.3.1 and previous I get all my macros available and running from within the Form when i open it form the external files. Now with ver 2.4.0 I can still open the Form but all macros are "lost", I can't see them at all as the Form doesn't contain them anymore. If I open the orginal Base (.odb) file that contains the Form and run it from within the Base file then all macros are still available and usable. I made some check to Security settings and tried both from network paths and local paths, with any result. This is the macro is created for the external form loading (the one I use with a button from external documents): '------------------------------------------------ Sub ApriFormSchedaFornitore Dim DatabaseContext as Object Dim DataSource as Object Dim Doc as Object Dim Form as Object Dim oFormDoc as Object Dim Forms Dim oParms(1) As New com.sun.star.beans.PropertyValue Dim I as Integer Dim names Dim dbExists as Boolean Dim subjectDb Dim oCon as Object subjectDb="schede_fornitori" If SwitchBoardOpen=True Then Exit Sub Else SwitchBoardOpen=true End If ' First look up the registered databases DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext") Names=DatabaseContext.getElementNames() dbExists=FALSE ' Now check to make sure the one we want is there. For I = 0 To UBound(Names()) If names(I)=subjectDb Then dbExists=TRUE EndIf Next If dbExists=True then ' msgbox("Database " & subjectDb & " Found") Else msgbox("Error: Unable to locate " & subjectDb & " Database") Exit Sub Endif 'XRay.XRay DatabaseContext ' Now go to that database and open the form we expect to be there ON Error GOTO OpenPhoneBookError DataSource=DatabaseContext.getByName(subjectDb) Doc=DataSource.DatabaseDocument Forms=Doc.GetFormDocuments Form=Forms.getByName("scheda_fornitore") oCon = DataSource.getConnection("", "") oParms(0).Name = "ActiveConnection" oParms(0).Value = oCon oParms(1).Name = "OpenMode" oParms(1).Value = "open" oFormDoc = Forms.loadComponentFromURL("scheda_fornitore", "", 0, oParms()) Exit Sub OpenPhoneBookError: msgbox("Error Occurred"& Err & Error$ & Erl ) On Error Goto 0 End Sub '------------------------------------------------ I made no changes to the macro and to any files, all is the same before and after I installed the 2.4.0 version. Simply, something in OOo has changed with regard or this. Could anyone confirm if this has a solution or workaround? Thank you
> Now with ver 2.4.0 I can still open the Form but all macros are "lost", > I can't see them at all as the Form doesn't contain them anymore. Are you saying that you do not see the form's macros in the Macro organizer (Tools/Macros/Organize/Basic) anymore? Or are you saying they just do not work anymore? > oParms(0).Name = "ActiveConnection" > oParms(0).Value = oCon > oParms(1).Name = "OpenMode" > oParms(1).Value = "open" As a workaround, try adding oParms(2).Name = "MacroExecutionMode" oParms(2).Value = com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE_NO_WARN here (of course you need to "Dim Parms(2) ..." then).
> Are you saying that you do not see the form's macros in the > Macro organizer (Tools/Macros/Organize/Basic) anymore? > Or are you saying they just do not work anymore? The first, I mean I can't see the macros in the Macro Organizer (if form is NOT open starting from the .odb file) >As a workaround, try adding > oParms(2).Name = "MacroExecutionMode" > oParms(2).Value = com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE_NO_WARN >here (of course you need to "Dim Parms(2) ..." then). Sorry, but i'm not experienced in macro language, so I'm in trouble even for adding something simple like this. I can add the 2 lines for "...Name..." and "...Value..." but I don't know how to add the "Dim oParms(2)..." Since I already have a similar line for variable "oParms(1)" I tried to duplicate it and just change "(1)" to "(2)" but running the macro i get a msg telling that variable "oParms" is already defined. Sorry.
Hi all, this behaviour is indeed new and not very funny. The former versions (before 2.4.0) did not show this problem. In the german OO forum this problem is described from several people who downgraded to an old OO Version. I found out that the MacroEcecutionMode tip "ALWAYS_EXECUTE_NO_WARN" work but all Macros opening a document must be modified.... Last but not least it is not only in database forms but with ALL documents which are opened indirectly by using a macro. sarotti
Hi, I think I may have the same problem within my database without external documents. It appears under Linux (Suse 10.3) and XP. In 2.2.1 it works fine! Discription: 1) Open Formular where several Macros are assigned to buttons or other items 2) No Macro can be executed 3) If you look at Tools/Macros/Organize/Basic you will see that no library is active, even standard is not active. (I know I have to activate other libraries but if I can't start with "standard" then I am blocked) 4) Open the Formular in the edit mode and switch to execution mode - all macros work fine, all libraries are activated. Sometimes I am lucky and can see that the standard library is activated. When I try to start macros manually, I get an error message saying that the macro cannot be executed because of security reasons. I have already set macro security to the lowest possible level but the message still appears. 5) downgrade to 2.2.1 and all macros are running without any problem. How can we increase the importance of this issue? To me it looks that nobody should be able to run macros in 2.4 databases. Thanks for any help! Andreas
fs->agrupe: I do not know what you mean with "Standard is not active" - I assume that you refer to the problem already mention above, namely that the macros in the form are not listed at all in the macro organizer. Okay, in my understanding the problem boils down to the fact that when you open a form programmatically, then macros in this form are not executed. In addition, the form's macros are not listed in the macro organizer. (Note I consider this two different problems, of different severity.) In 2.3.1, the user was asked whether or not to execute the macros, at the very time the form was opened. In 2.4, the question does not appear at all. Under the premise that this understanding is correct, I slightly change the summary to reflect this understanding, grab and confirm the issue. In addition, I target it to 2.4.1 - note however that this target is subject to approval by the release status team. See the releases@openoffice.org mailing list to follow the state of this approval.
Created attachment 53375 [details] document to reproduce the bug case
Created attachment 53376 [details] basic macro complementing the database document
If you register (Tools/Options/OpenOffice.org Base/Database) the attached i87741.odb as "i87741", the import the attached macro in the Basic IDE and run it, you're able to easily reproduce the problem. (cianoz, the macro is a slightly modified version of your original macro above, so credits for it are yours.)
Note the macro also contains a workaround: If you enable the two lines which specify a MacroExecutionMode when opening the form, then macro execution works as expected. Nonetheless, given that the unmodified version of the macro worked in 2.3.1 (and, btw, will work in 3.0, since the issue was fixed there, too), users should not need the workaround.
fixed in CWS dba241d find more information about this CWS, like when it is available in the master builds, in EIS, the Environment Information System: http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Path=DEV300%2Fdba241d
fs-> msc: please verify in CWS dba241d
verified in CWS dba241d find more information about this CWS, like when it is available in the master builds, in EIS, the Environment Information System: http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Path=OOH680%2Fdba241d
The modified macro with the workaround activated works, in effect. Thanks a lot for your help and for having handled this issue promptly. It's real good to see this kind of reactivity in the support/development community of our beloved software.
added "approved" to the title, because it will be easier to work with the 2.4.1 meta issue during release status meetings.
verified -> closed