title: VBA Zip File error
body: <p>I am using code similar to the below to add some files to a zip folder:</p>
  
  <pre><code>Set oApp = CreateObject("Shell.Application")
  oApp.Namespace(CVar(strDest)).CopyHere CVar(strSource)
  </code></pre>
  
  <p>This works fine most of the time, but sometimes I get an error:</p>
  
  <p>"(Compressed (zipped) Folders Error) Cannot create output file". This error is raised asynchronously outside of my VBA code and as such I cannot trap it to take remedial action.</p>
  
  <p>If I enter break mode and step back to:</p>
  
  <pre><code>oApp.Namespace(CVar(strDest)).CopyHere CVar(strSource)
  </code></pre>
  
  <p>then the file is added correctly. </p>
  
  <p>I am guessing that there is some kind of lock either on the compressed folder or the source file that is causing this problem, but I am unsure as to how to check this. I should note that the files are being added are pdf files created from Microsoft Access 2007 and we are using the fully qualified paths and the code runs as follows creating up to 10 pdfs per zip file:</p>
  
  <ol>
  <li><p>Create Zip</p></li>
  <li><p>Run this loop:</p></li>
  </ol>
  
  <pre>  For Each ReportToRun
      CreatePdf ' using DoCmd.OutputTo acOutputReport, "rptHame", acFormatPDF, strReportName
      AddToZip
    Next</pre>
  
  <p>Any idea how to either fix this or trap the Cannot create output file error?
  Thanks</p>