Forum at OOoForum.orgThe Forum
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How to convert open office (.sxw) to html

Post new topic   Reply to topic Forum Index -> Macros and API
View previous topic :: View next topic  
Author Message

PostPosted: Sun Feb 15, 2004 10:57 pm    Post subject: How to convert open office (.sxw) to html Reply with quote

How to convert open office (.sxw) to html from the Visual Basic 6 program.
What is the converter being used and the code as well in Visual Basic?
Back to top
OOo Advocate
OOo Advocate

Joined: 01 Feb 2003
Posts: 432
Location: Mexico

PostPosted: Sun Feb 15, 2004 11:12 pm    Post subject: Reply with quote

I dont get the Visual basic part, I mean, OOo can save as XHTML thanks to a XSLT plug-in created by members of the community.

Standard XHTML 1.0 code, however I dont see how this could be done on Visual Basic 6. Maybe making an XML tranformation using that XSLT convertor. However OOo already has this implemented.
Alexandro Colorado
PPMC Apache OpenOffice
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger

Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Mon Feb 16, 2004 7:53 am    Post subject: Reply with quote

You should ask this question in the Macros and API forum.

The following code should help you to do various document conversions in Visual Basic.
Private Sub Form_Load()
    ' Get the service manager, as a COM object.
    ' Everything else about OOo comes directly or indirectly from
    '  the Service Manager object.
    Set oServiceManager = CreateObject("")
    ' Get the Desktop object.
    Set oDesktop = oServiceManager.createInstance("")
    ' A document conversion consists of three steps.
    ' 1. Open a document.
    '    If the document is of a format that OOo automatically knows how to open
    '     then it is not necessary to use a filter.
    '    If OOo automatically uses a filter you don't want, or if OOo doesn't
    '     automatically know what filter to use, then you must specify
    '     which improt filter to use.
    ' 2. Save document.
    '    If you want to save the document in OOo's own native document format
    '     then no export filter is necessary.
    '    If you want to save in some foriegn document format, then you
    '     must specify an export filter.
    ' 3. Close the document.
    '========== Open Document ==========
    ' Open a document.  Use no import filter.
    ' OOo must be able to automatically recognize what import filter to used).
    Dim aNoArgs()
    ' Open an OOo native doucment test.sxw.
    Set oDoc = oDesktop.loadComponentFromURL("file:///C:/Test.sxw", "_blank", 0, aNoArgs())
    ' Open a MS Word document, test.doc.
'    Set oDoc = oDesktop.loadComponentFromURL("file:///C:/Test.doc", "_blank", 0, aNoArgs())
    ' Alternative...
    ' Open a document using an import filter.
'    Dim aOpenArgs(0) As Object
    ' Open an HTML document into Writer.
    ' (If we had not used this import filter, then OOo would automatically
    '  open HTML into Web, not Writer.)
'    Set aOpenArgs(0) = MakePropertyValue("FilterName", "HTML (StarWriter)")
'    Set oDoc = oDesktop.loadComponentFromURL("file:///C:/Test.html", "_blank", 0, aOpenArgs())
    ' Open an RTF document into Writer.
'    Set aOpenArgs(0) = MakePropertyValue("FilterName", "Rich Text Format")
'    Set oDoc = oDesktop.loadComponentFromURL("file:///C:/Test.rtf", "_blank", 0, aOpenArgs())
    '========== Save Document ==========
    ' Save document in native form.  Use no export filter.
'    Dim aNoArgs()
'    Call oDoc.storeToURL("file:///C:/Test.sxw", aNoArgs())
    ' Alternative...
    ' Save document using an export filter.
    Dim aSaveArgs(0) As Object
    ' Save document in MS Word format.
    Set aSaveArgs(0) = MakePropertyValue("FilterName", "MS Word 97")
    Call oDoc.storeToURL("file:///C:/Test.doc", aSaveArgs())
    ' Save document in Rich Text Format.
    Set aSaveArgs(0) = MakePropertyValue("FilterName", "Rich Text Format")
    Call oDoc.storeToURL("file:///C:/Test.rtf", aSaveArgs())
    ' Save document in PDF.
    Set aSaveArgs(0) = MakePropertyValue("FilterName", "writer_pdf_Export")
    Call oDoc.storeToURL("file:///C:/Test.pdf", aSaveArgs())
    ' Save document in HTML.
    Set aSaveArgs(0) = MakePropertyValue("FilterName", "HTML (StarWriter)")
    Call oDoc.storeToURL("file:///C:/Test.html", aSaveArgs())
    '========== Close Document ==========
    Call oDoc.Close(True)
End Sub

You need to comment and uncomment sections if you want to change the input format, or restrict the output formats.

The above code requires the MakePropertyValue() function, which can be found here.

The list of possible import and export filters to use can be found here...

Hope this helps.
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Forum Index -> 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