title: Excel VBA macro for opening files crashes without any error message
body: <p>for few years I've a macro somewhere from the internet which opens all files in selected folder and does something with them (changes something in all of them, merges them in one, changes column order etc.).</p>
  
  <p>For some reason, with some files the macro crashes without any error message. One day it crashes, the other day it does not. It crashes on my computer, as well as on there's computers or it doesn't crash on my computer and it crashes on there's computers etc... </p>
  
  <p>It crashes if there are 50 files in the folder or just two small files.</p>
  
  <p>There is only way I can make the macro run till the end is to create a breakpoint on <em>Set wb = Workbooks.Open(Pathname &amp; Filename)</em> and sometimes even on <em>Do Work wb</em>. And then I press just F5 when the macros stops on this breakpoint(s) and it does everything it should until it reaches the breakpoint again.</p>
  
  <pre><code>Public LastLine As Long
  Public final_file As String
  Public my_directory As String
  
  Sub ProcessFiles()
  Dim Filename, Pathname As String
  Dim wb As Workbook
  
  
  Application.AskToUpdateLinks = False
  Application.ScreenUpdating = False
  Application.DisplayAlerts = False
  Application.Calculation = xlCalculationManual
   Application.EnableEvents = False
  
  final_file = ActiveWorkbook.Name
  
  
  my_directory = InputBox("What's the name of the folder with the files?:", "What's the name of the folder with the files", "New files")
  Pathname = ActiveWorkbook.Path &amp; "\" &amp; my_directory &amp; "\"
  Filename = Dir(Pathname &amp; "*.xlsx")
  
  Do While Filename &lt;&gt; ""
      Set wb = Workbooks.Open(Pathname &amp; Filename)
      DoWork wb
      ActiveWindow.Close
      Filename = Dir()
  Loop
  
      LastLine = 0
  Application.ScreenUpdating = True
  Application.AskToUpdateLinks = True
  Application.DisplayAlerts = True
  Application.TransitionNavigKeys = False
  Application.Calculation = xlCalculationAutomatic
  Application.EnableEvents = True
  End Sub
  
  
  
  Sub DoWork(wb As Workbook)
     With wb
         'Here it does the tricks with each opened file
  
  End Sub
  </code></pre>
  
  <p>Do you have any idea what can be wrong with this?
  Thank you</p>