| Phoon Chee Keong 2005-08-30, 7:55 am |
| Anyone know how to do it? I only know how to open the openoffice
spreadsheet/writer from VB but not insert string/number to the sheet.
This is my code to open the file:
========================================
============
Sub firstOOoProc()
Dim oSM 'Root object for accessing OpenOffice from VB
Dim oDesk, oDoc As Object 'First objects from the API
Dim arg() 'Ignore it for the moment !
'Instanciate OOo : this line is mandatory with VB for OOo API
Set oSM = CreateObject("com.sun.star.ServiceManager")
'Create the first and most important service
Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
'Create a new doc
Set oDoc = oDesk.loadComponentFromURL("private:factory/scalc", "_blank",
0, arg())
'Close the doc
oDoc.Close (True)
Set oDoc = Nothing
'Open an existing doc (pay attention to the syntax for first argument)
Set oDoc = oDesk.loadComponentFromURL("file:///c:/test.sxc", "_blank", 0,
arg())
'Save the doc
Call oDoc.storeToURL("file:///c:/test.sxc", arg())
'Close the doc
oDoc.Close (True)
Set oDoc = Nothing
End Sub
========================================
=============
Rdgs
PCK
|