I am using code similar to the below to add some files to a zip folder:
Set oApp = CreateObject("Shell.Application")
oApp.Namespace(CVar(strDest)).CopyHere CVar(strSource)
This works fine most of the time, but sometimes I get an error:
"(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.
If I enter break mode and step back to:
oApp.Namespace(CVar(strDest)).CopyHere CVar(strSource)
then the file is added correctly.
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:
Create Zip
Run this loop:
For Each ReportToRun CreatePdf ' using DoCmd.OutputTo acOutputReport, "rptHame", acFormatPDF, strReportName AddToZip Next
Any idea how to either fix this or trap the Cannot create output file error? Thanks