| View previous topic :: View next topic |
| Author |
Message |
Tommy27 OOo Advocate


Joined: 18 Nov 2006 Posts: 300
|
Posted: Sun Jul 24, 2011 4:57 am Post subject: save and close document macro |
|
|
very simple macro that saves current OOo document and close it.
I assigned it to the "Esc" key
| Code: | sub SaveAndClose
dim document as object
dim dispatcher as object
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:Save", "", 0, Array())
ThisComponent.close(True)
end sub |
I found it useful as an "auto-save" workaround when closing a document without manually selecting the "Yes" or "No" saving dialog window |
|
| Back to top |
|
 |
DrBones General User

Joined: 07 Nov 2008 Posts: 15 Location: Long Island, NY
|
Posted: Fri Jul 29, 2011 3:19 pm Post subject: |
|
|
Hey Tommy27
What would you add to the code to "save the current record" for writer forms?
Thanks!
DrBones |
|
| Back to top |
|
 |
Tommy27 OOo Advocate


Joined: 18 Nov 2006 Posts: 300
|
Posted: Sun Jul 31, 2011 4:38 am Post subject: |
|
|
writer forms?
I don't understand... what do you mean exactly? |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Sun Jul 31, 2011 9:10 am Post subject: |
|
|
Hello
For saving data in a form use the basetools of Benitez.
and start a new thread this is off topic here
Romke |
|
| Back to top |
|
 |
tobski Newbie

Joined: 18 Sep 2012 Posts: 4 Location: Philippines
|
Posted: Sat Oct 06, 2012 2:05 am Post subject: Push Button save record and Close form |
|
|
I just copy the code:
sub SaveAndClose
dim document as object
dim dispatcher as object
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:Save", "", 0, Array())
ThisComponent.close(True)
end sub
and I get the below email.
Basic: Runtime Error
An exception occurred
Type:com.sun.star.util.closeVetoException Message:.
How I can make a push button where I can save record before closing the form. |
|
| Back to top |
|
 |
Tommy27 OOo Advocate


Joined: 18 Nov 2006 Posts: 300
|
Posted: Sun Nov 11, 2012 10:39 am Post subject: |
|
|
@tobski
that macro is intended for Writer documents.
it doesn't work in Base |
|
| Back to top |
|
 |
|