| View previous topic :: View next topic |
| Author |
Message |
noosh Newbie

Joined: 29 Jan 2006 Posts: 3
|
Posted: Sun Jan 29, 2006 9:34 am Post subject: How to close an calc file |
|
|
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
Thanks |
|
| Back to top |
|
 |
cjopp General User

Joined: 29 Jan 2006 Posts: 22
|
Posted: Sun Jan 29, 2006 2:02 pm Post subject: |
|
|
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 |
|
 |
|