Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Feb 2003
    Location
    Florida, USA
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word-Save As Macro (Word 2000)

    Need help for something simple and the Search facility is currently disabled, so.

    I am trying to save all files in a certain directory that are currently *.doc files as a .txt or text only with line breaks. (My software Monarch will not open the doc files) I tried a macro which would operate after I opened all files then would run the macro one at a time. But the macro recorderd hard codes the file name and I end up just overwriting the first file all the time. I can't figure out how to get around this limitation and have this macro accept the default file name but just save it with the new format.

    Any help would be appreciated
    Steve

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

    Re: Word-Save As Macro (Word 2000)

    Here is a simple macro. If you need to do this often, it could be made more user-friendly by letting the user browse for a folder to open. It could also be made more "modern" by using FileSystemObject, but that has been disabled in some corporate environments.

    Sub SaveAsText()
    Dim strPath As String
    Dim strFile As String
    Dim oDoc As Document
    strPath = InputBox("Please enter the path")
    If strPath = "" Then Exit Sub
    If Right(strPath, 1) <> "" Then strPath = strPath & ""
    strFile = Dir(strPath & strFile & "*.doc")
    Do While strFile <> ""
    Set oDoc = Documents.Open(strPath & strFile)
    oDoc.SaveAs strPath & Left(strFile, Len(strFile) - 3) & "txt", wdFormatText
    oDoc.Close False
    strFile = Dir
    Loop
    Set oDoc = Nothing
    End Sub

  3. #3
    Lounger
    Join Date
    Feb 2003
    Location
    Florida, USA
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word-Save As Macro (Word 2000)

    Hans,
    Thanks for the quick response. I am trying to run the Macro but seem to having problems with the following line-
    If Right(strPath, 1) <> "" Then strPath = strPath & ""

    I am getting a compile error and am afraid my VBA skills aren't good enough to figure this one out yet, but I am looking . . .

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

    Re: Word-Save As Macro (Word 2000)

    Hmm, I tested the macro on a folder with Word docs and it worked there. Two things to check:

    1. Some browsers don't display the "not equal to" sign (a "less than" immediately followed by a "greater than") correctly. If you see an ampersand & in it, that's the cause. I have attached a screenshot of what it should look like.

    2. Otherwise, select Tools | References... in the Visual Basic Editor. If you see MISSING, clear the corresponding check box, then click OK. Now try to run the query again.

  5. #5
    Lounger
    Join Date
    Feb 2003
    Location
    Florida, USA
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word-Save As Macro (Word 2000)

    Ohhhh--I think I have that issue--I just changed the code because I couldn't find the MISSING in the Tools|References. So I will give it a whirl.

    Thanks for the help--gets me out of a tight spot!
    Steve

Posting Permissions

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