Results 1 to 4 of 4

Thread: Make Word save file as "Web Page, Filtered"

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    774

    Make Word save file as "Web Page, Filtered"

    I am using MS Word's ability to save a file in HTML format to create a very basic website CMS system. Files must be saved with a .htm extension in the "Web Page, Filtered" file format that is available in Word 2007 and 2010 (not sure about earlier versions). My VB program is used to remove some unwanted tags from the files and then transfer them to the website via FTP. I thought it would be neat to initiate the editing of a file from my program, so I used ProcessStartInfo to "shell" to "winword.exe" and open the file for editing. All good so far; the problem is if the user clicks "close" in Word and answers "yes" to the "save changes?" question, the file is saved in "normal" HTML format, not the Filtered version that I need. The resulting file is bloated with Word junk which I don't want.

    So, is there any way to force Word to save in my desired "Web Page, Filtered" format? If it can't be done with a "shell" process, could it be done with Word Automation? I have seen mention of a "winword control"; could something like that be made to work?

    Any ideas appreciated.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Make Word save file as "Web Page, Filtered"

    It should take all of 5 seconds to realise that the answer to this is no. You've made yourself a hostage to fortune by yielding up control to Word and whoever is operating it at the time. How would you go about wresting it back. You could conceivably set up a filewatcher to register that the file has been changed and check that it's in the correct format before proceeding but my guess is that that would be a bit hit and miss.

    So my best advice is to disabuse yourself of the notion that any such beast as "a file in HTML format" exists. It's a text file, plain and simple, and if you edit it as a text file the need for filtering out Microsoft's incompatible bloat simply never arises. In any case, from the description of what your program's intended to do it's difficult to understand why anything other than automated (and automatic) editing would be considered necessary. Given the chance to edit for themselves, your users will have the power to do all kinds of things to your output that you'd rather they didn't, not just to remove the filter!
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    774

    Re: Make Word save file as "Web Page, Filtered"

    It wont be a big deal to instruct my users (both of them!) that they must save the document as "Web Page, Filtered", and I can at least check that they have done so before uploading the file. I might check out what is possible with Automation and/or integration of Word as an editor within my program - a bit like an email client that uses Word as an editor.

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Make Word save file as "Web Page, Filtered"

    Word is frankly a terrible option for editing HTML! If you want a WYSIWYG editor there are plenty available for nowt and it's no wasted exercise to program your own. If you don't then a simple textbox is as good an editor as any!
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width