Results 1 to 4 of 4
  1. #1
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Word as text editor (final par mark) (2002 SP-2)

    I'm thinking it would be kinda nice to be able to enlist the mighty Word as a simple text editor, so I could make use of macros & other handy features when I'm editing text files. Is there a simple way to make Word save a document as a text file without adding a final CrLf?

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

    Re: Word as text editor (final par mark) (2002 SP-2)

    I don't think so. You could write a macro that
    - Saves the document as a text file.
    - Closes it.
    - Uses the VB text file instructions to remove the last line end.
    But is it really necessary?

  3. #3
    5 Star Lounger
    Join Date
    Oct 2002
    Location
    Wellington, Wellington, New Zealand
    Posts
    621
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word as text editor (final par mark) (2002 SP-2)

    It's very rare to see text files without a final CRLF pair - generally that would be an error, even in a text editor such as notepad

  4. #4
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Word as text editor (final par mark) (2002 SP-2)

    Thanks for both responses. I was focusing on text files that would be data storage vehicles whose contents would be read by code (Scripting.TextStreams and the like), and I was concerned that having a CrLf at the end would effectively mean the file contained a bogus empty "final record." But after a little experimentation, it looks like that may not be an issue. Using either the Scripting.TextStream.ReadLine method or VB's Line.Input method to loop through a sample file, I get the same result whether there's a CrLf at the end of the last record or not -- i.e., the added CrLf doesn't cause either code method to detect an extra record at the end.

    Word-format files always have final CrLf's because certain formatting is stored there. WordPerfect doesn't use paragraph marks that way, so a WordPerfect file don't have a final CrLf unless you want to add it. Since text files don't have any formatting to store, I'm not sure why a typical text file would end in a CrLf, but if it does, that certainly makes me more comfortable with the idea of using Word as a text editor (without having to implement some kind of SaveAsTextFileAndClose macro that strips the final CrLf after the file is out of Word's clutches).

Posting Permissions

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