For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > August 2005 > vb export to openoffice









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author vb export to openoffice
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



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com