title: Saving new Excel document as macro-free workbook without prompt
body: <p>I'm using Excel 2010. I have an Excel macro-enabled template that has a data connection to a text file that is set to automatically refresh when a new document is created using this template.</p>
  
  <p>The following macro is within the "ThisWorkbook" object to remove the data connection before saving the new document:</p>
  
  <pre><code>Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
  
      Do While ActiveWorkbook.Connections.Count &gt; 0
          ActiveWorkbook.Connections.Item(ActiveWorkbook.Connections.Count).Delete
      Loop
  
  End Sub
  </code></pre>
  
  <p>When a user clicks the save icon / hits ctrl+S, inputs a filename and then clicks save to save as a macro-free Excel workbook (as is the default and required filetype) they are prompted with a message stating:</p>
  
  <blockquote>
    <p>The following features cannot be saved in macro-free workbooks:</p>
    
    <p>• VB project</p>
    
    <p>To save a file with these features, click No, and then choose a
    macro-enabled file type in the File Type list.</p>
    
    <p>To continue saving as a macro-free workbook, click Yes.</p>
  </blockquote>
  
  <p>Is it possible to prevent this message from appearing and have Excel assume that the user wants to continue with a macro-free workbook?</p>
  
  <p>I've searched all over and understand that I may be able to add code to the workbook object that removes itself so that Excel has no VB project to cause this message but this would require each user to change Trust Center Settings (Trust access to the VBA project object model) which I want to avoid.</p>
  
  <p>I've also seen suggestions of using:</p>
  
  <pre><code>Application.DisplayAlerts = False
  </code></pre>
  
  <p>but can't get this to work. Every example of it's use seems to be within a sub that is also handling the saving of the document whereas in my situation the BeforeSave sub ends before the document is saved in the default, non-vba way which is perhaps why it does not work?</p>
  
  <p>Does this property reset to a default True after the sub has ended / before the save actually occurs?</p>
  
  <p>Apologies for any nonsense I may have dispensed, my experience with VBA is very limited.</p>