• Open as Text in Word 2007 (Word 2007)

    Author
    Topic
    #454896

    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

    Viewing 0 reply threads
    Author
    Replies
    • #1130404

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

      • #1130408

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

        • #1130420

          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

          • #1130529

            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

            • #1130538

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

            • #1130539

              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

            • #1130542

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

              The VBA equivalent is

              Documents.Open FileName:="_overview.htm", _
              Format:=wdOpenFormatEncodedText, _
              Encoding:=msoEncodingUTF8

    Viewing 0 reply threads
    Reply To: Open as Text in Word 2007 (Word 2007)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: