Consulting

Results 1 to 6 of 6

Thread: Force MS Word to Open and Save all Text Files in MS DOS encoding

  1. #1

    Force MS Word to Open and Save all Text Files in MS DOS encoding

    I have hundreds of text files in a folder that's incorrectly formatted. I had to open each text file in MS Word. And to correct it, open in MS DOS encoding, search and replace all Non-ASCII and then save the file in the same MS DOS encoding. Any idea how to get started?

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,335
    Location
    For the Batch part you can start with:

    http://gregmaxey.mvps.org/word_tip_p...der_addin.html
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    Thanks Greg. What I'm really struggling is to force open the file in a set text encoding, e.g. MS-DOS encoding.

    Sub myRoutine()
    Dim file
    Dim path As String
    
    path = "C:\Reports\"
    
    file = Dir(path & "*.txt")
    Do While file <> ""
    Documents.Open FileName:=path & file
    
    'subroutine to force MS Word to open text in MS-DOS encoding
    'search and replace non-ASCII characters to standard format
    'save text file in MS-DOS encoding 
    
    file = Dir()
    Loop
    End Sub

  4. #4
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,335
    Location
    How are you opening it in MS-DOS encoding manually?
    Greg

    Visit my website: http://gregmaxey.com

  5. #5
    Hi Greg
    First I open the text file in MS Word. Since the file is not in plain text format (or was not formatted as plain text), it prompts user to select a text encoding format. I select MS-DOS encoding instead of Windows format.

    sharma_unrecognizable_documents_1.jpg

  6. #6
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,335
    Location
    Your picture leads one to believe you want to open in Other encoding "Japanese"

    For MS-DOS try

    Documents.Open FileName:="db1.mdb, Encoding:=437
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

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