Liang Weike wrote: > Hello all, > > Recently I get a piece of Basic macro and test it in my computer. But I > met problems when running it. The problem can be described as follows: > > 1. Open a new writer document. Save it as whatever.odt. > 2. Select Tools -> Macros -> Organize Macros -> OpenOffice.org Basic... >>from the menu to open the OpenOffice.org Basic Macros dialog. > 3. Create whatever.odt a new module, with the following macro: > -------------------------------------------- > REM ***** BASIC ***** > > Sub Main > oFrame=thiscomponent.getcurrentcontroller.getFrame > dim args(0) as new com.sun.star.beans.PropertyValue > oFrame.loadComponentFromURL("private:factory/swriter", "_self",23, args) > End Sub > -------------------------------------------- > 5. Save whatever.odt and close it. > 6. "Enable Macros" on reopening whatever.odt. > 7. Reopen the module we created above in the editing window. > 8. Run the module from the toolbar. And the application crashes, instead > of opening a new writer document as expected.
When executed from inside the IDE the macro replaces the BasicIDE with the new Writer document as that's what you told OOo to do. Obviously this lets the IDE crash. Though I think that there's never an excuse for a crash I think it will be quite hard to fix it here. Perhaps the IDE should prevent itself from being disposed while a macro inside is running. But this will also prevent your macro from successful execution. My recommendation is to call loadComponentFromURL at the global "StarDesktop" object. Ciao, Mathias -- Mathias Bauer (mba) - Project Lead OpenOffice.org Writer OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS Please don't reply to "[EMAIL PROTECTED]". I use it for the OOo lists and only rarely read other mails sent to it. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]