title: VB Script RefreshAll in folder (with exception)
body: <p><em>edited to be more specific:</em></p>
  
  <p><code>VBScript</code> below runs through entire folder, <strong>opens each *.XLSM file there</strong>, refreshes all data connections and saves updated files one by one. Files are also password protected, but it's not that important.</p>
  
  <p>How to enhance the code to AVOID files in folder, based on part or entire  <strong>filename</strong>? For an example avoid filenames ending with <code>z</code> however with still <code>.xlsm</code> extension.</p>
  
  <p><em>Expected outcome for files located in the same folder:</em></p>
  
  <blockquote>
    <p>abc123.xlsm (refresh); abc123z.xlsm (avoid); file.xlsm (refresh);
    testz.xlsm (avoid)</p>
  </blockquote>
  
  <pre><code>Set fso = CreateObject("Scripting.FileSystemObject")
  Set xl  = CreateObject("Excel.Application")
  xl.Visible = False
  
  For Each f In fso.GetFolder("C:\test\").Files
    If LCase(fso.GetExtensionName(f.Name)) = "xlsm" Then
  
      Set wb = xl.Workbooks.Open(f.Path ,,,,,"x")
  
      wb.RefreshAll
      wb.Save
      wb.Close
  
    End If
  
  Next
  
  xl.Quit
  </code></pre>