title: VBA script convert folder of .rtf files to .docx files - two minor problems
body: <p>I use a VBA script (see below) in Word 2013 to convert a folder of .rtf files to .docx files. It mostly works, but has two minor problems.</p>
  
  <ol>
  <li>I have to acknowledge that each original file is an .rtf file. When Word opens each .rtf file there's a dialog that requires me to confirm that each file is an .rtf file.</li>
  <li>When I view converted .docx files in Word there's a "compatibility mode" header, which suggests that I haven't properly converted.</li>
  </ol>
  
  <p>Are there any fixes for these problems? The first one kind of undermines the whole point of scripting and I'm afraid the second one will cause unforeseen problems.</p>
  
  <pre><code>Sub ConvertRtfToDocx()
  
      Set oWord = CreateObject("Word.Application")
  
      With Application.FileDialog(msoFileDialogFolderPicker)
          .Title = "Select folder..."
          .Show
          myFolder = .SelectedItems.Item(1)
      End With
  
      myWildCard = InputBox(prompt:="Enter wild card...")
  
      myDocs = Dir(myFolder &amp; "\" &amp; myWildCard)
  
      While myDocs &lt;&gt; ""
          Debug.Print myDocs
          Set oDoc = oWord.Documents.Open(myFolder &amp; "\" &amp; myDocs)
          oDoc.SaveAs myFolder &amp; "\" &amp; Left(myDocs, Len(myDocs) - 4) &amp; ".docx", _
              wdFormatXMLDocument
          myDocs = Dir()
      Wend
      oWord.Quit
  
  End Sub
  </code></pre>