I made a quite complex Basic macro in Calc that, at the end of its work, closes all temporary sheets it created, saves all documents (with appropriate .store instructions) and finally closes OpenOffice completely by using StarDesktop.Terminate.
The macro works well and documents are correctly saved, but at the next start of Calc, invariably the "document restore" window appears with the name of the spreadsheet where the macro was included. In fact there is nothing to restore and the spreadsheet gets restored anyway, but I do not want to force my user to always see the restore window and to click two times to confirm. But, if I try to start Calc with the "-norestore" option, the restore window appears anyway.
So I can solve my problem in two ways:
- Close the macro cleanly, so that there is no need to restore the document. But what can I do, besides using store and terminate? I understand that the problem is due to the macro closing itself.
- Open next time with a working norestore option, but this does not work (i am on Windows 10, with OpenOffice 4.1.5).
Some advices? Thank you!
Close from macro and norestore
Close from macro and norestore
OpenOffice 4.1.5 on Windows 10
Re: Close from macro and norestore
Sometimes code needs delay loops inserted to permit actions complete before subsequent commands are executed.
I have a memory that this problem came up before and I doubt any solution was found: consider this - the macro closes the file (itself). Then where does it return to for its next instruction, even if that is only an "end sub"?
I have a memory that this problem came up before and I doubt any solution was found: consider this - the macro closes the file (itself). Then where does it return to for its next instruction, even if that is only an "end sub"?
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: Close from macro and norestore
Just a guess - what if you store the macro in My Macros so you can close the document cleanly and then terminate OpenOffice?
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Close from macro and norestore
The StarDesktop.Terminate method cannot be executed from a document macro. That this results in the recovery issue is bad. The command should be rejected.
An application macro can do it if no veto is thrown by any listener. I just tested this in AOO 4.1.5 and in LibO 6.1.3 with the StartDesktop.Terminate in the last line of the macro. Of course you are back to your issue if you call that application macro from a document macro.
An application macro can do it if no veto is thrown by any listener. I just tested this in AOO 4.1.5 and in LibO 6.1.3 with the StartDesktop.Terminate in the last line of the macro. Of course you are back to your issue if you call that application macro from a document macro.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
Re: Close from macro and norestore
I think it will not be possible for me to usa an application macro instead of a document macro.
But I could have a working solution if the online option -norestore were working on next start of Calc. Is i just not working in this version, or for all Windows versions at all?
But I could have a working solution if the online option -norestore were working on next start of Calc. Is i just not working in this version, or for all Windows versions at all?
OpenOffice 4.1.5 on Windows 10