Customised Open Document Macro works first time round, but hangs and/or crashes the second time around

Hi Everyone

So I created a library module in a different file (a Writer file called READMEFIRST) that has a push button that when clicked copies the files over to the Standard Library in My Macros on the destination computer. So my .odb should never hang any more.

I used Listing 527 in Pitonyak’s chapter cited in soko192’s message to help me write the macro.

The only fun I had was distinguishing between the destination library container (on the destination computer) and the container on the source computer. In case it helps anybody else:

oDestLibs = GlobalScope.BasicLibraries  ' this is the destination library container object on the home computer
oSrcLibs =  oComponent.BasicLibraries   ' this is the source library container object of the current document

Thanks to all who have me this far.

Best Wishes,

CB

2 Likes

@CandidoBandido : Only one hint: The Standard library will often be cleared from content. Just opened LO 25.8.0.2 and the library is empty again. So I won’t save anything in this library except test procedures.

To be honest, I never ever has such an accident. And I work with very many releases. Such a thing is an own bug.

Problem with this buggy behavior: I couldn’t write a step by step description to reproduce it. But it just had happened when I opened LO 25.8.0.2 and want to test the code reported above. Whole library had been cleared. No problem for me, because I have seen it before and only use it for testing.

I have also tested the procedure with database @sokol92 had attached. If Base is the only open component the desktop disappears. But when having a look at the open processes LibreOffice is still there in the background with 946,4 MB. So it isn’t really closed under OpenSUSE 15.6 Linux together with LO 25.8.0.2

Okay.

For me, the library is still there today!

But - Belt and Braces - I will write a procedure to test whether or not the library module exists when I start the .odb app and exit the app with a message to reload the library (and reboot the computer!) if it’s not there…

And thanks again for all your help!

Best wishes,

CB

In Win10 LO 25.2.5.2 Task Manager also shows that the LibreOffice process exists. Perhaps (?) this is the process responsible for Start Сenter. It doesn’t seem to have any negative consequences for me.


My macro only asynchronously closes the .odb file (any document). We can also write a macro that (asynchronously) closes the application:

  • closes BasicIDE (if open)
  • sets the status of the modified-flag of open documents to False
  • closes StarDesktop

The macros don’t have to be in the Standard library. I created a new library named CloseAsync and moved the macros from the Standard library to CloseAsync.
In the open document event use:

GlobalScope.BasicLibraries.loadLibrary("CloseAsync")

Have create a separate library for this and changed the code for AsyncClose_notify a littel bit. Now StarDesktop will be closed complete if no frame is still open. Seems to work well here. Hope also users with Windows and Mac, which are using my Base-files, won’t find a buggy behavior here.

Sub AsyncClose_notify(arg) 
    arg.Close(True)
	oFrames = StarDesktop.Frames
	n = oFrames.Count
	IF n = 0 THEN StarDesktop.Terminate()
End Sub
1 Like