Click here to Skip to main content
13,594,656 members
Click here to Skip to main content
Add your own
alternative version


35 bookmarked
Posted 28 Aug 2005

Document conversion with OpenOffice

, 28 Aug 2005
Rate this:
Please Sign up or sign in to vote.
Convert documents to HTML and PDF using OpenOffice.

Sample Image - oo2html.png


This is a document conversion application. It converts docs from OpenOffice format to HTML and PDF. It could easily be modified to open any OpenOffice supported document. See the OpenOffice website for a list of supported formats.


As project manager for a dev team, I needed a way to keep all design docs current on the intranet. We save all our project documentation in the CM system. So, I built a little app that scans the CM directory for OpenOffice files (either doc or spreadsheet), converts them to HTML and PDF, then copies them to the web server with an updated index.html file.

The code is quite simplistic, but solves a problem that people might run into regularly. So, I wanted to set it free.

This example works with both OpenOffice 1.1.4 and 1.9 beta.

Using the code

The code is quite easy, once you figure out all the tricks. I am just using the script interface for OpenOffice to open a file, then save in another format.

I noticed that there was some similar code for VB, so I figured it should probably work for VB.NET, and it did! I have no idea if C# has the same CreateObject functionality.

Dim objServiceManager As Object
    objServiceManager = CreateObject("")
Catch ex As Exception
    Throw New Exception("OpenOffice is not installed" & vbCrLf & ex.ToString())
End Try

The ServiceManager is used to a create a desktop. The desktop is used to open a document. Then the document is saved with a filter, which is similar to using the "Save as" feature in OpenOffice. I specify "HTML (StarWriter)" to save OpenOffice format to HTML. Pretty easy, huh?

Per the introduction, my app also copies the docs to the web server. So, it requires "from" and "to" arguments. The example in the picture above would be:

oo2html "c:\test\" "C:\Program Files (x86)\xampp\htdocs\test"

Points of Interest

As mentioned above, this app could be modified to do any conversion that is possible with OpenOffice. For example, you could open all *.doc files instead of *.sxw, then output them to HTML. Or, it could open HTML files and output to doc. You get the picture.


My original version was more robust to solve my particular problem. It updated the CM Tree, and only copied files with a certain naming convention, among other things. I have trimmed it down considerably, in hopes of making it more straightforward.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralUpdate Pin
ggraham41220-Jun-08 8:11
memberggraham41220-Jun-08 8:11 
Question"Can't Create ActiveX Object" - OpenOffice Pin
Ailton Silva3-Oct-07 9:31
memberAilton Silva3-Oct-07 9:31 
QuestionProblem when using open office in web application Pin
RathiSarov10-Oct-06 11:04
memberRathiSarov10-Oct-06 11:04 
AnswerRe: Problem when using open office in web application Pin
Member 323966118-Mar-09 20:16
memberMember 323966118-Mar-09 20:16 
Did u ever solve this ? Please help me. I am also facing a similar problem
AnswerRe: Problem when using open office in web application Pin
KaNNaN.JC17-Feb-10 22:58
groupKaNNaN.JC17-Feb-10 22:58 
GeneralProblem using similiar code in ASP.NET Pin
ashutosh99107-Sep-06 0:44
memberashutosh99107-Sep-06 0:44 
GeneralRe: Problem using similiar code in ASP.NET Pin
Member 323966118-Mar-09 20:17
memberMember 323966118-Mar-09 20:17 
GeneralHelp on create OpenOffice file Pin
mpx2009-Aug-06 23:22
membermpx2009-Aug-06 23:22 
GeneralIs it possable not to install full openoffice Pin
lukethepunk4-Aug-06 4:12
memberlukethepunk4-Aug-06 4:12 
GeneralRe: Is it possable not to install full openoffice Pin
duwke4-Aug-06 4:17
memberduwke4-Aug-06 4:17 
GeneralRe: Is it possable not to install full openoffice Pin
Kacee Giger14-Nov-06 10:06
memberKacee Giger14-Nov-06 10:06 
GeneralRe: Is it possable not to install full openoffice Pin
lukethepunk16-Nov-06 7:13
memberlukethepunk16-Nov-06 7:13 
AnswerRe: Is it possable not to install full openoffice Pin
toastpooter7-Jun-07 6:21
membertoastpooter7-Jun-07 6:21 
GeneralConvert from Doc to PDF Pin
intranet_man24-Apr-06 5:58
memberintranet_man24-Apr-06 5:58 
GeneralRe: Convert from Doc to PDF Pin
duwke24-Apr-06 6:29
memberduwke24-Apr-06 6:29 
GeneralRe: Convert from Doc to PDF Pin
intranet_man24-Apr-06 6:43
memberintranet_man24-Apr-06 6:43 
GeneralRe: Convert from Doc to PDF Pin
duwke24-Apr-06 6:47
memberduwke24-Apr-06 6:47 
GeneralRe: Convert from Doc to PDF Pin
intranet_man24-Apr-06 7:12
memberintranet_man24-Apr-06 7:12 
GeneralMail Merge Pin
richardsawyer2-Oct-05 1:11
memberrichardsawyer2-Oct-05 1:11 
GeneralAttachment Pin
Quinton Viljoen30-Aug-05 19:42
memberQuinton Viljoen30-Aug-05 19:42 
GeneralRe: Attachment Pin
duwke30-Aug-05 19:53
memberduwke30-Aug-05 19:53 
GeneralRe: Attachment Pin
Quinton Viljoen30-Aug-05 20:17
memberQuinton Viljoen30-Aug-05 20:17 
GeneralRe: Attachment Pin
dgsconseil31-Aug-05 0:39
memberdgsconseil31-Aug-05 0:39 
GeneralRe: Attachment Pin
duwke31-Aug-05 3:04
memberduwke31-Aug-05 3:04 
GeneralRe: Attachment Pin
Quinton Viljoen31-Aug-05 3:17
memberQuinton Viljoen31-Aug-05 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180621.3 | Last Updated 28 Aug 2005
Article Copyright 2005 by duwke
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid