| View previous topic :: View next topic |
| Author |
Message |
roanny Guest
|
Posted: Sun Feb 15, 2004 10:57 pm Post subject: How to convert open office (.sxw) to html |
|
|
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 |
|
 |
JZA OOo Advocate


Joined: 01 Feb 2003 Posts: 432 Location: Mexico
|
Posted: Sun Feb 15, 2004 11:12 pm Post subject: |
|
|
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
http://es.openoffice.org |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Mon Feb 16, 2004 7:53 am Post subject: |
|
|
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.
| Code: | 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("com.sun.star.ServiceManager")
' Get the Desktop object.
Set oDesktop = oServiceManager.createInstance("com.sun.star.frame.Desktop")
'-----
' 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.
http://www.oooforum.org/forum/viewtopic.php?p=22029#22029
The list of possible import and export filters to use can be found here...
http://www.oooforum.org/forum/viewtopic.php?t=3549
http://www.oooforum.org/forum/viewtopic.php?p=15416#15416
http://www.oooforum.org/forum/viewtopic.php?t=3545
http://www.oooforum.org/forum/viewtopic.php?t=3175
http://www.oooforum.org/forum/viewtopic.php?p=10311#10311
Hope this helps. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
|
|
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
|