HTML to WordML -- and vice versa

Posted on 2004-11-23
Last Modified: 2008-03-04
How do I create a standalone application that opens an HTML file as a Word document? Also, how do I later save this Word document into HTML? I want to be able use Word's functionality, if possible. I tried adding a Word reference to my project, but could not declare such an object:

' squiggly line under "Word"
Dim objWord as Word

I figured I might be able to use Word's methods and properties to do this.
Question by:xmlnewbie
    LVL 10

    Accepted Solution


    here's the code to convert a word document to html

    void DocToHtml(string docPath,string htmlPath)
    Word.Application app=new Word.Application();
    Object o=Missing.Value;
    object docFile=docPath;
    _Document doc=app.Documents.Open(ref docFile,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref
    object fileName=htmlPath;
    object format=8;//Html
    doc.SaveAs(ref fileName,ref format,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o);
    object t=true;
    app.Quit(ref t,ref o,ref o);

    Author Comment

    What does that mean??
    LVL 10

    Expert Comment

    also u can check the link below:

    for further details

    its for the same as above.

    Expert Comment

    OK so this converts from Word to HTML. How do you convert from HTML to WordML? I'ma ssuming the only change is the format # but I don't know what that is.

    Also, is there a way to do this without loading the WINWORD.EXE COM object?

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now