OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

save and close document macro

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
Tommy27
OOo Advocate
OOo Advocate


Joined: 18 Nov 2006
Posts: 300

PostPosted: Sun Jul 24, 2011 4:57 am    Post subject: save and close document macro Reply with quote

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
View user's profile Send private message
DrBones
General User
General User


Joined: 07 Nov 2008
Posts: 15
Location: Long Island, NY

PostPosted: Fri Jul 29, 2011 3:19 pm    Post subject: Reply with quote

Hey Tommy27

What would you add to the code to "save the current record" for writer forms?

Thanks!

DrBones
Back to top
View user's profile Send private message
Tommy27
OOo Advocate
OOo Advocate


Joined: 18 Nov 2006
Posts: 300

PostPosted: Sun Jul 31, 2011 4:38 am    Post subject: Reply with quote

writer forms?

I don't understand... what do you mean exactly?
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2696
Location: Apeldoorn, Netherland

PostPosted: Sun Jul 31, 2011 9:10 am    Post subject: Reply with quote

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
View user's profile Send private message
tobski
Newbie
Newbie


Joined: 18 Sep 2012
Posts: 4
Location: Philippines

PostPosted: Sat Oct 06, 2012 2:05 am    Post subject: Push Button save record and Close form Reply with quote

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
View user's profile Send private message Send e-mail Yahoo Messenger
Tommy27
OOo Advocate
OOo Advocate


Joined: 18 Nov 2006
Posts: 300

PostPosted: Sun Nov 11, 2012 10:39 am    Post subject: Reply with quote

@tobski

that macro is intended for Writer documents.
it doesn't work in Base
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group