• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 528
  • Last Modified:

Convert Word to HTML on the fly

What I’m trying to is the following...
I am trying to convert a word doc to an html file on the fly. Something like this, they upload a word doc then it opens a new page with their document now converted to HTML. Does someone have an example on how to convert or know of a good tutorial that can help me out?

Thanks in advance, Bo
1 Solution
Open your file and save it in html!!!
If you want to automate this, here is my suggestion:

Create a simple COM object using VB6.  This object has one base method you execute with the path to the word document and a name for the html file.

The VB6 object will execute the SHELL command which will in turn execute the MS html filter for office applications on the selected word document.  This will create a clean (depending on the options configured) version of you word document in html format.

Here is a link to the MS Html filter for download and instructions for use.  If you need info or help on creating the COM object I will be glad to help.


Also, there are freeware versions of COM objects already written that would allow you to execute the html filter without writing your own object.

vargasboAuthor Commented:
This all has to be web-base, so a simple save-as won't work. I'm a pretty new to asp so how would I call the COM object from within the Page?
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Some host in the web have an option that all the file you uploaded will be converted to html files.  You have to choose whether you want to convert it or not.  Actually when I make a webpage to upload.  I use notepad instead of Word and save it as "filename.htm."
A COM object is called either by its registerd class id (a guid) or by the assigned name (in Visual Basic this would be the Project Name "." Class Name).

So, if you write a visual basic object and named the project Scripting and a class within the project (you can have multiple) WebTools, your vbscript syntax would be:

Dim objShell

Set objShell = Server.CreateObject("Scripting.WebTools")
objShell.DocToHtml( strInputFile, strOutputFile )

Here is a sample class file for the VB app: (I'm not testing this so there may be sytax errors)

Dim ActiveApps As Integer
Private Declare Function GetNumTasks Lib "Kernel" () As Integer

Public Sub DocToHtml( string strInputFile, _
                      string strOutputFile, _
                      optional boolean boolA = false, _
                      optional boolean boolB = false, _
                      optional boolean boolC = false, _
                      optional boolean boolF = false, _
                      optional boolean boolL = false, _
                      optional boolean boolM = false, _
                      optional boolean boolO = false, _
                      optional boolean boolR = false, _
                      optional boolean boolS = false, _
                      optional boolean boolT = false, _
                      optional boolean boolV = false, _
                      optional boolean boolX = false)
    Dim strCommand As String
    Dim Y As Integer
    Dim X As Integer
    ActiveApps = GetNumTasks()
    strCommand = "filter "
    if boolA then
        strCommand = strCommand & " -A"
    end if
    if boolB then
        strCommand = strCommand & " -B"
    end if
    if boolC then
        strCommand = strCommand & " -C"
    end if
    if boolF then
        strCommand = strCommand & " -F"
    end if
    if boolL then
        strCommand = strCommand & " -L"
    end if
    if boolM then
        strCommand = strCommand & " -M"
    end if
    if boolO then
        strCommand = strCommand & " -O"
    end if
    if boolR then
        strCommand = strCommand & " -R"
    end if
    if boolS then
        strCommand = strCommand & " -S"
    end if
    if boolT then
        strCommand = strCommand & " -T"
    end if
    if boolV then
        strCommand = strCommand & " -V"
    end if
    if boolX then
        strCommand = strCommand & " -X"
    end if

    strCommand = strCommand & " " & strInputFile & " " & strOutputFile

    X = Shell( strCommand, 5 )
    Do While GetNumTasks() <> ActiveApps
        Y = DoEvents()
End Sub

MSDN reference to Shell Command:

vargasboAuthor Commented:
thanks for all the help, I have a solid place to start from now.
What about giving the users Macromedia's Contribute and letting them drag and drop their Word files straight into the web pages? The html code it creates is about the same as what  you get from a SaveAs from Word 2000. Not exactly clean code but it works in post-version 4 browsers.
M Child

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now