Dim objserviceManager As Object
Dim objDesktop As Object
Dim objDocument As Object
Dim args()
Public Sub openoffice()
Set objserviceManager = CreateObject("com.sun.star.ServiceManager")
'Create the Desktop
Set objDesktop = objserviceManager.createInstance("com.sun.star.frame.Desktop")
'args is the necessiory params
Set objDocument = objDesktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, args)
Set oSheet = objDocument.getSheets().getByIndex(0)
With oSheet
For i = 1 To 9
For j = 1 To 9
.getCellByPosition(i, j).setString (i & "*" & j & "=" & i * j)
Next
Next
End With
End Sub
Private Sub cmDwrite_Click()
Call openoffice
End Sub
Private Sub Command1_Click()
Dim open_office_name As String
open_office_name = "calc.ods"
'xxx = "file:///" & Replace(xxx, "/","\/
Path = Replace(App.Path & "\" & open_office_name, "\ ", "/")
objDocument.storeToURL "file:///" & Path, args
objDocument.Close (True)
Label1.Caption = "Have write the file to your computer the path is : " & App.Path & "\" & open_office_name
End Sub