title: VBA loop through files remove password
body: <p>I am trying to remove passwords from multiple .xlsm files in one folder. I have written the following code, but doesn't seem to be working. I do not recieve any error however. Any help would be appreciated to figure out what I'm missing.</p>
  <pre><code>Sub RemovePasswords()
  
      Dim xlBook As Workbook
      
      Dim strFilename As String
      
      Dim strPassword As String
      
      Dim strEditPassword As String
      
      Dim fpath As String
      
      Application.EnableEvents = False
      
          fpath = &quot;C:\Users\User525\Desktop\Test Group\&quot;        'The folder to process, must end with &quot;\&quot;
      
          strFilename = Dir$(fpath &amp; &quot;*.xls&quot; &amp; vbNormal) 'will open xls &amp; xlsx etc
          strPassword = &quot;Password&quot;
          strEditPassword = &quot;&quot;
          
       While Len(strFilename) &lt;&gt; 0
              Application.DisplayAlerts = False
              Set xlBook = Workbooks.Open(Filename:=fpath &amp; strFilename, _
                                          Password:=strPassword, _
                                          WriteResPassword:=strEditPassword)
              xlBook.SaveAs Filename:=fpath &amp; strFilename, _
                            Password:=&quot;&quot;, _
                            WriteResPassword:=&quot;&quot;, _
                            CreateBackup:=True
              xlBook.Close 0
              Application.DisplayAlerts = True
              strFilename = Dir$()
          Wend
      Application.EnableEvents = True
  End Sub
  </code></pre>