Results 1 to 8 of 8
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open as Text in Word 2007 (Word 2007)

    Seems like in previous versions of Word there was a way to open a document as text in Word. Perhaps you can only do that through a macro. Either way I need to know how.

    I am hoping to do so in order to run a macro for complex search and replacing WITHOUT adding extra junk Word would add to them.

    Thanks!!
    Troy

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open as Text in Word 2007 (Word 2007)

    Do you mean Word documents (.doc or .docx) or text files (.txt)?

  3. #3
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open as Text in Word 2007 (Word 2007)

    Yes. Sorry, I should have said that. I am talking about opening txt files or actually "htm" files.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open as Text in Word 2007 (Word 2007)

    Click the big Office button.
    Select Word Options.
    Activate the Advanced tab
    Tick the "Confirm file format conversion on open" check box.
    Click OK.
    Next time you open a .htm file, Word will prompt you how to open it. If you open it as a text file, Word will treat it as plain text. This also means that you'll see the HTML coding.

    The VBA code to open a .htm file as text looks like this:

    Documents.Open FileName:="C:MyDocsMyWebPage.htm", Format:=wdOpenFormatText

  5. #5
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open as Text in Word 2007 (Word 2007)

    That is great information! Just what I was looking for.

    However, I have found another problem. If I open as plain text, it adds some funny characters to my file in several places. The file is actually XML but with an HTM extension on the file name.

    Thus, when I try to open it, it tries to open as XML by default. If I do that, all I see in word are these XML tags and not the same text I see when I open in Notepad. If there is a way to see the same text I see in Notepad without adding all the funny characters, that would be great.

    Thanks again for your help!!
    Troy

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open as Text in Word 2007 (Word 2007)

    I'm not sure what's happening. Could you zip a sample file and attach it to a reply?

  7. #7
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open as Text in Word 2007 (Word 2007)

    OK. I have attached a file. I stripped a lot of the content out, so don't worry about that. It should be enough to see what I am dealing with.

    Thanks again!!
    Troy
    Attached Files Attached Files

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open as Text in Word 2007 (Word 2007)

    Try selecting Encoded Text in the conversion dialog, with Unicode (UTF-8) as encoding.

    The VBA equivalent is
    <code>
    Documents.Open FileName:="_overview.htm", _
    Format:=wdOpenFormatEncodedText, _
    Encoding:=msoEncodingUTF8</code>

Posting Permissions

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