title: SaveAs PPTM to PPTX
body: <p>I need to turn a batch of pptm files into pptx. I tried to repurpose VBA code that turns xlsx files into xls files. The macro opens an xlsx file in a designated folder, saves it as an xls file, closes it, and moves on to the next file until all are converted. The original macro code was:</p>
  <pre class="lang-vb prettyprint-override"><code>Sub ProcessFiles()
      Dim Filename, Pathname, saveFileName As String
      Dim wb As Workbook
      Dim initialDisplayAlerts As Boolean
      Pathname = &quot;&lt;insert_path_here&gt;&quot;  ' Needs to have a trailing \
      Filename = Dir(Pathname &amp; &quot;*.xlsx&quot;)
      initialDisplayAlerts = Application.DisplayAlerts
      Application.DisplayAlerts = False
      Do While Filename &lt;&gt; &quot;&quot;
      Set wb = Workbooks.Open(Filename:=Pathname &amp; Filename, _
                              UpdateLinks:=False)
      wb.CheckCompatibility = False
      saveFileName = Replace(Filename, &quot;.xlsx&quot;, &quot;.xls&quot;)
      wb.SaveAs Filename:=Pathname &amp; saveFileName, _
                FileFormat:=xlExcel8, Password:=&quot;&quot;, WriteResPassword:=&quot;&quot;, _
                ReadOnlyRecommended:=False, CreateBackup:=False
      wb.Close SaveChanges:=False
      Filename = Dir()
      Loop
      Application.DisplayAlerts = initialDisplayAlerts
  End Sub
  </code></pre>
  <p>I modified it in the following way:</p>
  <pre class="lang-vb prettyprint-override"><code>Sub ProcessFiles()
      Dim Filename, Pathname, saveFileName As String
      Dim ppPres As Presentation
      Dim initialDisplayAlerts As Boolean
      Pathname = &quot;\\TRIFS03\RoamingProfiles\user\Documents\projectfolder\testfolder\&quot;  ' Needs to have a trailing \
      Filename = Dir(Pathname &amp; &quot;*.pptm&quot;)
      initialDisplayAlerts = Application.DisplayAlerts
      Application.DisplayAlerts = False
      Do While Filename &lt;&gt; &quot;&quot;
      Set ppPres = Presentations.Open(Filename:=Pathname &amp; Filename, _
                              UpdateLinks:=False)
      ppPres.CheckCompatibility = False
      saveFileName = Replace(Filename, &quot;.pptm&quot;, &quot;.pptx&quot;)
      ppPres.SaveAs Filename:=Pathname &amp; saveFileName, _
                FileFormat:=ppSaveAsOpenXMLPresentation, Password:=&quot;&quot;, WriteResPassword:=&quot;&quot;, _
                ReadOnlyRecommended:=False, CreateBackup:=False
      ppPres.Close SaveChanges:=False
      Filename = Dir()
      Loop
      Application.DisplayAlerts = initialDisplayAlerts
  End Sub
  </code></pre>
  <p>I get</p>
  <blockquote>
  <p>Compile Error Named Argument Not Found</p>
  </blockquote>
  <p>pointing to <code>UpdateLinks:=</code>.</p>
  <p>I did some research and found that I should delete this bit of code. I was left with the following:</p>
  <pre class="lang-vb prettyprint-override"><code>Sub ProcessFiles()
      Dim Filename, Pathname, saveFileName As String
      Dim ppPres As Presentation
      Dim initialDisplayAlerts As Boolean
      Pathname = &quot;\\TRIFS03\RoamingProfiles\user\Documents\projectfolder\testfolder\&quot;  ' Needs to have a trailing \
      Filename = Dir(Pathname &amp; &quot;*.pptm&quot;)
      initialDisplayAlerts = Application.DisplayAlerts
      Application.DisplayAlerts = False
      Do While Filename &lt;&gt; &quot;&quot;
          Set ppPres = Presentations.Open(Filename:=Pathname &amp; Filename)
          ppPres.CheckCompatibility = False
          saveFileName = Replace(Filename, &quot;.pptm&quot;, &quot;.pptx&quot;)
          ppPres.SaveAs Filename:=Pathname &amp; saveFileName, _
                FileFormat:=ppSaveAsOpenXMLPresentation, Password:=&quot;&quot;, WriteResPassword:=&quot;&quot;, _
                ReadOnlyRecommended:=False, CreateBackup:=False
          ppPres.Close SaveChanges:=False
          Filename = Dir()
      Loop
      Application.DisplayAlerts = initialDisplayAlerts
  End Sub
  </code></pre>
  <p>I got</p>
  <blockquote>
  <p>Compile Error Method or Data Member not Found</p>
  </blockquote>
  <p>pointing to <code>.CheckCompatability =</code>.</p>
  <p>I tried deleting THAT one.</p>
  <blockquote>
  <p>Compile Error Named Argument Not Found</p>
  </blockquote>
  <p>pointing to <code>Password:=</code>.</p>
  <p>I decided to look for a new macro:</p>
  <pre class="lang-vb prettyprint-override"><code>With ActivePresentation
      .SaveCopyAs _
        FileName:=.Path &amp; &quot;\&quot; &amp; Left(.Name, InStrRev(.Name, &quot;.&quot;)) &amp; &quot;pptx&quot;, _
        FileFormat:=ppSaveAsOpenXMLPresentation
  End With
  </code></pre>
  <p>I added loop code and ended up with:</p>
  <pre class="lang-vb prettyprint-override"><code>Sub ProcessFiles()
      Dim Filename, FileFormat As String
      Dim initialDisplayAlerts As Boolean
      initialDisplayAlerts = Application.DisplayAlerts
      Application.DisplayAlerts = False
      Do While Filename &lt;&gt; &quot;&quot;
          .SaveCopyAs _
            Filename:=.Path &amp; &quot;\&quot; &amp; Left(.Name, InStrRev(.Name, &quot;.&quot;)) &amp; &quot;pptx&quot;, _
            FileFormat:=ppSaveAsOpenXMLPresentation
          ppPres.Close SaveChanges:=False
          Filename = Dir()
      Loop
      Application.DisplayAlerts = initialDisplayAlerts
  End Sub
  </code></pre>
  <p>Which ended up with</p>
  <blockquote>
  <p>Compile Error Invalid or Unqualified Reference</p>
  </blockquote>
  <p>with <code>.Path</code> being pointed to as the culprit.<br />
  According to the <a href="https://stackoverflow.com/questions/18289234/save-powerpoint-pptm-to-pptx">code’s author</a> (see top voted answer), I shouldn’t need to define <code>.Path</code> if I’m using <code>\</code>.</p>