[SOLVED] CloseVetoException

Creating and using forms
Post Reply
Jjs2060
Posts: 60
Joined: Sat Nov 08, 2014 2:53 am

[SOLVED] CloseVetoException

Post by Jjs2060 »

I get an error from the following sub: Basic runtime error: an exception occurred. Type: com.sun.star.util.CloseVetoException. What's the problem.
Thanks for the help. Here is the sub:

dim oDoc as object
oDoc = ThisComponent
If hasUNOInterfaces(oDoc,"com.sun.star.util.XCloseable") then
oDoc.close(true)
else
oDoc.dispose()
End If

End Sub
Last edited by floris v on Thu May 07, 2015 8:41 am, edited 2 times in total.
Reason: Added green checkmark for Solved, edited Solved tag
Libre Office 4.2.2.1 on OS X 10.9.3
User avatar
MTP
Volunteer
Posts: 1620
Joined: Mon Sep 10, 2012 7:31 pm
Location: Midwest USA

Re: CloseVetoException

Post by MTP »

It's a bad idea for a document to try to close itself. If your macro opens an "outside" document then it can close this outside document without any effect on the document the macro is "running out of" and that's fine. Or you can run script from outside of OpenOffice that opens and closes OpenOffice documents. But if a macro is running from inside a document and tries to close that document, you get a chicken-and-egg problem: the document can't close until the macro finishes running, and the macro can't finish running until the document is closed.
OpenOffice 4.1.1 on Windows 10, HSQLDB 1.8 split database
Jjs2060
Posts: 60
Joined: Sat Nov 08, 2014 2:53 am

SOLVED Re: CloseVetoException

Post by Jjs2060 »

Thanks for your direction. I'll throw a different path.
Libre Office 4.2.2.1 on OS X 10.9.3
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: CloseVetoException

Post by B Marcelly »

MTP wrote:It's a bad idea for a document to try to close itself.
It depends. You must have nothing pending when you close.

A case that comes to my mind : if your macro works in a dialog, you cannot close the document since the dialog is not yet closed. Close the dialog first, then close the document.
Another case : you have started a printout and you try to close before it is finished.
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
Jjs2060
Posts: 60
Joined: Sat Nov 08, 2014 2:53 am

Re: [SOLVED] CloseVetoException

Post by Jjs2060 »

This macro is triggered from a button on a form. I'm done with the form an want to close it. What's creating the error?
Libre Office 4.2.2.1 on OS X 10.9.3
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: [SOLVED] CloseVetoException

Post by B Marcelly »

.odb documents are special beasts...

How to close the current form from the button, but keep the Base document open :

Code: Select all

Sub closeThisForm
StarDesktop.CurrentFrame.close(True)
End Sub
How to close the form and close the Base document :

Code: Select all

Sub closeFormAndBase
ThisDatabaseDocument.close(True)
End Sub
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
Jjs2060
Posts: 60
Joined: Sat Nov 08, 2014 2:53 am

Re: [SOLVED] CloseVetoException

Post by Jjs2060 »

Thanks sooooooooo much.
Libre Office 4.2.2.1 on OS X 10.9.3
Post Reply