I was also having similar issue. After going through and trying all the methods described here, I finally decided to outsource the fix by calling another program to close OO.
Assuming you are in Windows environment... I created an AutoIt3 program to look for Window title of the document and call "WinClose" on that window. See attached file for code (you'll need to first rename the extension to .au3, and then use AutoIt3 to compile it)
Then in your macro, do something like this...
Code: Select all
Dim vShell as Variant
vShell = createUnoService("com.sun.star.system.SystemShellExecute")
vShell.execute("C:\AutoIt3\CloseOODoc.exe", "Learn-OO-program.odt", 0)
The execute line's first parameter is the path to the compiled script. 2nd parameter is the title of the file to close.
Edit: Uploaded version 1.1 - added an optional parameter to specify number of ms to pause before execution. Default is 1000ms (1s). This maybe important because it's not possible to close OpenOffice while BASIC is still running. This waits for BASIC to exit before closing OO. |