Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    249
    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 13:14. Reason: Added Code Tags

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,879
    Thanks
    0
    Thanked 184 Times in 169 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]

  4. #3
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    249
    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
  •