Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    251
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Need macro to convert folder full of .DOCX files to .RTF format

    Hello,

    I am using MS Word 2010 and I need to convert a folder full of .docx files to .rtf format.
    This is because the .rtf format provides a cleaner import into FrameMaker, than the .docx format.

    The macro below shows .rtf to .docx and I need it to point the other way around (convert folder full of .docx files to .rtf format).

    With that said, I appreciate any assistance you can provide.
    Swapping the rtf and docx around in the code did not work for me.

    Thanks in advance for any suggestions.

    Regards,

    -J

    --------------------------------------------------------------------------------------------
    Code:
    Sub UpdateDocumentFormats()
    Application.ScreenUpdating = False
    Dim strFolder As String, strFile As String, wdDoc As Document
    strFolder = GetFolder
    If strFolder = "" Then Exit Sub
    strFile = Dir(strFolder & "\*.rtf", vbNormal)
    While strFile <> ""
      Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
      With wdDoc
        .SaveAs2 FileName:=Left(.FullName, InStrRev(.FullName, ".")) & "docx", Fileformat:=wdFormatXMLDocument, AddToRecentFiles:=False
        .Close wdDoNotSaveChanges
      End With
      strFile = Dir()
    Wend
    Set wdDoc = Nothing
    Application.ScreenUpdating = True
    End Sub
    
    Function GetFolder() As String
    Dim oFolder As Object
    GetFolder = ""
    Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
    If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
    Set oFolder = Nothing
    End Function
    Last edited by RetiredGeek; 2014-02-07 at 14:14. Reason: Added Code Tags

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,944
    Thanks
    0
    Thanked 203 Times in 184 Posts
    Use:
    Code:
    strFile = Dir(strFolder & "\*.docx", vbNormal)
    ...
    .SaveAs2 FileName:=Left(.FullName, InStrRev(.FullName, ".")) & "rtf", Fileformat:=wdFormatRTF, AddToRecentFiles:=False
    PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    251
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks Paul!!! It works great.

Posting Permissions

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