Apache OpenOffice (AOO) Bugzilla – Issue 59047
Macros in a new document based on a template did not work
Last modified: 2013-02-24 21:08:00 UTC
If a new document is produced based on a Template (i.e. *.ott) and template will have (Basic-) Macros inside, these Macros are not accessible before the new document has no URL (is stored). Try the following way: open a new Document (text). Write a short macro and store it in Module1, Standard library, inside the document. Store the document as *,ott (template), close it. Now open the template (*.ott) with a double-click on the name, an new untitled writer-document will be open. Try Extras - Makro - Makros ausführen... (sorry, just a german version) and the dialog will only display two Sections: MyMakros and OpenOffice.org Macros. Ther is no display of the document macros, therefor you cannot start it. Even if yo try to start it via a button or anything else, you will get an com.sun.star.uno.RuntimeExeption. Only way to access the macro is: Extras - Makro - Makros verwalten - OpenOffice.org Basic. In this dialog the document-Macros are accessible and you can push the button "execute". So it is not possible to start a macro in a document which was created via template and do not have a URL. This behavier is different to the 1.1.x line, where we do not have any problems on this.
Created attachment 32206 [details] template with macro
sw->thomaskrumbein: I've attached a template and when I open it inside OOo I can access the macro at the created Untitled1 without problem ... what do I miss ?
-> sw: well, your dokument works. So I will give you some more details: effect occurs obviously only, when ther is minimum one form inside of the Document. So I add some contolls to your document (two text-controls and one button), the button is connected to your makro. Create a new document based on the new template, push the button -> Error as mentioned prior. Even you cannot access teh macro via Extras - Makro - Makros ausführen... - no document-Macros are available. Then give the document an URL -> everything ok.
Created attachment 32209 [details] Template with mcro and form
sw->thomaskrumbein: mmmm ... also with your sample I have no problem with accessing the macro ... not with OOo2.0 and not with the development build OOo_m3_8968 ... any ideas what I'm missing ? ... I just opened the template and then chose "Tools-Macro-Run Macro ...", which showed me Untitled1 and so I could start the macro.
-> sw: No. I can reproduce this error at any time - even with other documnents. My Way: I have stored this template (macro_tk.ott) local on my computer (System Win XP, SP2). I use the Windows-Explorer and make a double-Klick on the filename -> OOo starts and produce a new document in writer (untitled1). When I try to push the button, a msgbox appears and told me: Title: OpenOffice.or g Fehler, message: com.sun.star.uno.RuntimeExeption. Picture attached (Fehler1.jpg). And I cannot access the document macros (fehler2.jpg). My System: OOo m142 build 8984 But: a customer mentioned this problem - send me his file and i could reproduce the error. Then I create new documents and can reproduce again. When I opened your document everything work ok. I did not store the new created doc, then I add some controls and try to combine the macro to the button. When the window (dialog) come up to select the macro-name, there where no document-macros listed, even the place "unbekannt1" was not listed. So I store first the document, then assign the macro to the button. Same problem???
Created attachment 32212 [details] Error -message
Created attachment 32213 [details] error picture2
Created attachment 32214 [details] orginal file customer
I just try your modified doc on an different computer (Win XP, OOo 2.0.1) - well, works ok ???? then I try the orginal Doc, which creates the problems by my customer an even on my computer -> well, error is again reproduceble. So I put the orginal doc in attachment - please use confidential. The doc covers a form with two controls, the macro is assign to "Lost Focus" of the second control -> Aktenzeichen. Maybe it helps?
Seems the one has to close the document in between ... well at least then I could reproduce it. What I did 1. open the office 2. open the document macro_tk.ott 3. press the button => a message box greeting you appears 4. close the document 5. open it again 6. press the button => a RuntimeException appears 7. choose "Tools-Macro-Run Macro" => the document "Untitled1" isn't available The Office needs to be closed and opened again to make the macro work ... or the document has to be saved. sw->tbe: I send it to you since my first guess would be that something with the scripting framework is faulty.
changing owner
TBE->AB: Something for you.
this might be a duplicate to issue 58527?
Yes, most probably a duplicate to issue 58527 -> set to DUPLICATE, will check again when issue 58527 is resolved *** This issue has been marked as a duplicate of 58527 ***
verified in OOo 2.0.2 -> close