title: Excel VBA - Open Workbooks, Run Macro, Save & Close
body: <p>I have a macro that open all the .xls files in a folder then run a macro to do something to that files, saves and closes them as .xls.
  My purpose is to save the files but as .xlsx files.
  I've allready tryed use FileFormatNum = 51, FileFormat = 51 but none of them worked.</p>
  
  <p>If someone has a better approach i appreciate the help.</p>
  
  <pre><code>Sub OpenSave()
  Dim myfiles, wb As Workbook, ws As Worksheet
  myfiles = Dir(ThisWorkbook.Path &amp; "\*.xls")
  Do While Len(myfiles) &lt;&gt; 0
  Debug.Print myfiles
  Set wb = Workbooks.Open(ThisWorkbook.Path &amp; "\" &amp; myfiles)
     ' Do your stuff here (edit, copy, sort etc...)
  Call a Macro
  If wb.Name &lt;&gt; ThisWorkbook.Name Then
  ActiveWorkbook.Close SaveChanges:=True
  Set wb = Nothing
     myfiles = Dir
     End If
  </code></pre>
  
  <p>Loop
  End Sub</p>
  
  <p>The macro has adapted from some code i see in a site.</p>