title: Disable all dialog boxes in Excel while running VB script?
body: <p>I have some code in VB that saves all XLSM files as XLSX. I already have the code that will do that for me, but dialog boxes show up for every action. This was fine for a few dozen files. However, I'm going to use this on hundreds of XLSM files at once, and I can't just sit at my computer all day clicking dialog boxes over and over. </p>
  
  <p>The code I've tried is pretty much:</p>
  
  <pre><code>Application.DisplayAlerts = False
  </code></pre>
  
  <p>While this doesn't cause an error, it also doesn't work. </p>
  
  <p>The boxes give a warning about enabling macros, and also warn that saving as XLSX strips the file of all macros. Considering the type of warnings, I suspect that they've restricted turning off those dialog boxes due to the security risk. </p>
  
  <p>Since I'm running this code in Excel's VB editor, is there perhaps an option that will allow me to disable dialog boxes for debugging?</p>
  
  <p>I've also tried:</p>
  
  <pre><code>Application.DisplayAlerts = False       
  Application.EnableEvents = False        
  ' applied code
  Application.DisableAlerts = True
  Application.EnableEvents = True
  </code></pre>
  
  <p>Neither of those worked. </p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Here's what the code above looks like in my current code:</p>
  
  <pre><code>Public Sub example()
  Application.DisplayAlerts = False
  Application.EnableEvents = False
  
  For Each element In sArray
      XLSMToXLSX(element)
  Next element
  
  Application.DisplayAlerts = False
  Application.EnableEvents = False
  End Sub
  
  Sub XLSMToXLSX(ByVal file As String)
      Do While WorkFile &lt;&gt; ""
          If Right(WorkFile, 4) &lt;&gt; "xlsx" Then
              Workbooks.Open Filename:=myPath &amp; WorkFile
  
              Application.DisplayAlerts = False
              Application.EnableEvents = False
  
              ActiveWorkbook.SaveAs Filename:= _
              modifiedFileName, FileFormat:= _
              xlOpenXMLWorkbook, CreateBackup:=False
  
              Application.DisplayAlerts = True
              Application.EnableEvents = True
  
              ActiveWorkbook.Close
          End If
          WorkFile = Dir()
      Loop
  End Sub
  </code></pre>
  
  <p>I also surrounded the <code>For</code> loop, as opposed to the <code>ActiveWorkbook.SaveAs</code> line:</p>
  
  <pre><code>Public Sub example()
  For Each element In sArray
      XLSMToXLSX(element)
  Next element
  End Sub
  </code></pre>
  
  <p>Finally, I shifted the <code>Application.DisplayAlerts</code> above the <code>Workbooks.Open</code> line:</p>
  
  <pre><code>Sub XLSMToXLSX(ByVal file As String)
      Do While WorkFile &lt;&gt; ""
          If Right(WorkFile, 4) &lt;&gt; "xlsx" Then
              Workbooks.Open Filename:=myPath &amp; WorkFile
  
              Application.DisplayAlerts = False
              Application.EnableEvents = False
  
              ActiveWorkbook.SaveAs Filename:= _
              modifiedFileName, FileFormat:= _
              xlOpenXMLWorkbook, CreateBackup:=False
  
              Application.DisplayAlerts = True
              Application.EnableEvents = True
  
              ActiveWorkbook.Close
          End If
          WorkFile = Dir()
      Loop
  End Sub
  </code></pre>
  
  <p>None of those work as well.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I'm using Excel for Mac 2011, if that helps. </p>