is There a usable macro on hand,
to trigger from a button in a Base Form,
a clean exit from DB and LibO(V5) ?
I’ll take it ! Bob
This button exists… its the
X button in the up|right corner of the window
Q closes ALL open instances of LO and not just your .odb - including any writer, calc, math, draw, or impress windows which are open. With that, here is the function:
sub loQuit document = ThisComponent.CurrentController.Frame dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") dim args1(0) as new com.sun.star.beans.PropertyValue dispatcher.executeDispatch(document, ".uno:Quit", "", 0, args1()) end sub
This may work to just close the .odb and related open form:
sub CloseDoc document = ThisComponent.getParent().getCurrentController().getFrame() document.close(1) end sub
Further testing was done using the above routines. All tests were done on Linux systems.
Sub “loQuit” works without a problem in LO v18.104.22.168 but using v22.214.171.124 there is an abnormal exit when the routine is called from a push button or custom toolbar item. It does work in v126.96.36.199 when run directly from Basic IDE.
Sub “CloseDoc” executes from a push button in v188.8.131.52 and v184.108.40.206 but does not completely shut down LO. Ironically, under both versions, if the
document.close(1) statement is actually executed within MRI, there is a complete shutdown without any side effects. There is no explanation for this at this point and it is not the first time I saw this type of thing happen. The other occurrence has eluded me for over a year.
The above "LoQuit code
- gives" an UNEXPETED ERROR on activating the macro from a QUIT LIBREOFFICE button in the Form!
- and leaves a .lck file in the DB directory.
So I deactivate the button and label it with “quit with CRTL/Q”
@kirsch Will edit my answer with further findings/explanation.
Hi Karolus, about your comment
That upper right corner “X” button does not the job properly in my case:
I start the database by opening a Form from start, the usual DB development window is not on screen (hidden). When I click the X button in the Form, the form-window closes leaving a LibreOffice process running! And it gives trouble later on when I try to start a other DB. Closing that Form trough its menu File->Close does the un-clean exit and leaves a unneeded and unwanted LibreOffice running process.
The only clean Exit from that is using in the Form the menu choice File->Quit LibreOffice (Of course it needs the menu bar in the Form) or I can use CTRL/Q to quit LibO.
But in my application, I’d like to have a nice button in the form to do that CTRL/Q action.
Thanks anyway for your comment Karolus, it makes me explain my problem more pecisely.