[Solved] Convert Word docs to HTML Using API

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
ghayyurh
Posts: 5
Joined: Tue Oct 04, 2016 8:48 pm

[Solved] Convert Word docs to HTML Using API

Post by ghayyurh »

Hi All,

I am looking for help to convert word docs to HTML using Open Office API. Please advise which packages (namespaces) should I use from Open Office to convert word docs to HTML in my code? I can find these packages in MS word API, but can't find in Open Office. Please help?

Thanks,
Last edited by Hagar Delest on Thu Oct 06, 2016 9:45 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 4.1 on Windows 10
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Convert Word docs to HTML Using API

Post by JohnSUN-Pensioner »

See Andrew Pitonyak "Useful Macro Information" - chapter 5.17.1. Filter names and Listing 5.44: Export a document.
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
ghayyurh
Posts: 5
Joined: Tue Oct 04, 2016 8:48 pm

Re: Convert Word docs to HTML Using API

Post by ghayyurh »

Thanks for the reply.

Here is my use case.

I want to upload the word doc in my application, and want to see it in the browser in HTML format. I will really appreciate if you can help me with the code on how to take in word doc and convert it to HTML in the browser. I am using C# .NET for my development. Please help!

Thanks in advance.
OpenOffice 4.1 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Convert Word docs to HTML Using API

Post by Villeroy »

This is totally unrelated to OpenOffice.
OpenOffice is the reference application for the Open Document Format.
https://en.wikipedia.org/wiki/Apache_OpenOffice
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Convert Word docs to HTML Using API

Post by UnklDonald418 »

Here is the Basic code to export the current OO Writer document as HTML

Code: Select all

    REM  *****  BASIC  *****
   
    
Sub SaveDocAsHTML

DIM sURL as string
Dim args2(1) As New com.sun.star.beans.PropertyValue

oDoc = ThisComponent
args2(0).Name = "InteractionHandler"
args2(0).Value = ""
args2(1).Name = "FilterName"
args2(1).Value = "HTML (StarWriter)"   '"HTML" REM One of the HTML export filters
REM Use the correct file extension
sURL = "file:///c:/Users/Owner/test_file.html"
oDoc.storeToURL(sURL,args2())
End Sub
I've never used C#.NET so I can't say how to translate this to your application. Generally the API calls are the same, but declaring the variables and setting up the array will probably need to be changed.
Last edited by UnklDonald418 on Thu Oct 06, 2016 5:52 pm, edited 1 time in total.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
ghayyurh
Posts: 5
Joined: Tue Oct 04, 2016 8:48 pm

Re: Convert Word docs to HTML Using API

Post by ghayyurh »

Thanks a million for the help!
OpenOffice 4.1 on Windows 10
Post Reply