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

How to close an calc file

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
noosh
Newbie
Newbie


Joined: 29 Jan 2006
Posts: 3

PostPosted: Sun Jan 29, 2006 9:34 am    Post subject: How to close an calc file Reply with quote

Smile Hi,
the following macro open a calc file
Code:

Sub ouvertureFichier()
Dim ShExec As Object
Dim Fichier As String

Fichier = "C:\classeur1\document2.ods"
ShExec = createUnoService("com.sun.star.system.SystemShellExecute")
ShExec.execute(Fichier , "", 0)
End Sub

How can I close this calc file Question
Thanks
Back to top
View user's profile Send private message
cjopp
General User
General User


Joined: 29 Jan 2006
Posts: 22

PostPosted: Sun Jan 29, 2006 2:02 pm    Post subject: Reply with quote

Hi,
if you want to do something with a document you open, you shouldn't let the OS open it for you.
Open it with OOo and you keep controll over it:
Code:

Dim oDoc As Object
   
Sub openDoc
   Dim sDocPath As String
   Dim Args() As new com.sun.star.beans.PropertyValue
   
   sDocPath = ConvertToURL("/home/user/documents/someDoc.ods") 'for Linux
   'for Windows: sDocPath = ConvertToURL("c:\someFolder\someDoc.ods")
   
   oDoc = StarDesktop.LoadComponentFromURL(sDocPath,"_default",0,Args())
   
   oDoc.close(true) 'with that line you close the document
   
End Sub


But be aware this closes the document and doesn't save any changes.
If you want to do that, you have to insert oDoc.store() before the close command in the example above.

Hope that helps
Christoph
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 Macros and API 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