Exit LO, Windows

I have a calc spreadsheet carrying a macro. When I have finished running it, having saved and closed all open files, I wish to exit LO. Whichever way I try, File/exit LO, CRTL Q or clicking the top right ‘X’, I am left with at least one running libre office process in Task Manager, a lock file and on restart a ‘recovery’ process for the original ods file.

How do I just cleanly quit LO?

Do you have the BASIC editor open still?
Go to Task Manager, click the arrow before LibreOffice if there is one to open a list of all the processes associated with LO. Then right-click the LibreOffice entry and select “Go to details.” Now see if soffice.exe, scalc.exe, etc. are running.

Joshua - thanks for the response. No. I did, as I said, but since posting I have found this snippet from someone helpful to close the programme, which it does without ‘residual’ LO processes,

Dim oSvc as object
'msgbox " Closing OpenOffice" & chr$(10) & " Goodbye…", 0, " --WARNING-- "
oSvc = createUnoService(“com.sun.star.system.SystemShellExecute”)
ThisComponent.close(true) ’ >> close the internal file first
’ pass the required parameters to execute a clean shutdown of soffice.exe
wait 2000
oSvc.execute(“c:\windows\system32\taskkill.exe”, " /F /IM soffice.exe /T" , 0) ’ >> windows vista/7 syntax

but every time it resumes with a call to ‘recover’ the ods which seems unnecessary? Any idea how can I get rid of that call each time?

As an addendum, Joshua, although I have no residual LO showing, when I restart the macro, get the ‘recover file’ process which I ‘decline’, I am left, after closing the process down (using Windows ‘X’) with two instances of LO running in Task Manager, one of which is showing 50% CPU usage and shows both soffice exe and soffice bin running!

You can try therapy instead of surgery. :slightly_smiling_face:
The IDE (LibreOffice Basic) window should be closed.

Sub LOTerminate()
  Dim oDoc As Object
  For Each oDoc In StarDesktop.Components
    If HasUnoInterfaces(oDoc, "com.sun.star.util.XModifiable") Then
      oDoc.setModified False    
    End If  
  Next oDoc
  
  StarDesktop.Terminate  
End Sub

Thanks, soko - already had a similar code snippet to do that. I am still left with the ‘recover file’ problem.

This may be due to an earlier error in your code.
Try to upload as short a sample .ods file as possible and describe the steps that lead to the situation you describe.

This may be due to an earlier error in your code.

Spot on! Grateful thanks. In the process of so-doing I discovered I had over-enthusiastically ‘executed’ a Dialog twice which I think was causing the problem.

So, I am beating myself with birch twigs and stopping my pocket-money for a week… :slight_smile: