title: Macro loop through all files in a folder
body: <p>Im trying to get a macro to loop through all the files in a folder and run a macro on it. So far I have:</p>
  
  <pre><code>Sub ProcessFiles()
      Dim Filename, Pathname As String
      Dim Wb As Workbook
  
      Pathname = "C:\Trading\TICK\PROBAB\DATA\CURRENT\"
      Filename = Dir(Pathname &amp; "*.xlsm")
      Do While Filename &lt;&gt; ""
          Workbooks.Open (Pathname &amp; Filename)
          Application.Run "storage.xlsm!ALL"
          Filename = Dir()
      Loop
  
  
  End Sub
  </code></pre>
  
  <p>The problem is, after the first iteration it fails. I know it is something to do with the second macro, as if I take it out, all the files in the folder will open.</p>