I am using code similar to the one below to add some files to the zip folder:
Set oApp = CreateObject("Shell.Application")
oApp.Namespace(CVar(strDest)).CopyHere CVar(strSource)
This works fine in most cases, but sometimes I get an error:
"(Compressed (compressed) folder error) Unable to create output file." This error occurs asynchronously outside of my VBA code, and therefore I cannot capture it in order to take corrective measures.
If I enter break mode and return to the following point:
oApp.Namespace(CVar(strDest)).CopyHere CVar(strSource)
then the file will be added correctly.
I assume there is some kind of lock either in the compressed folder or in the source file that causes this problem, but I'm not sure how to check it. I should note that the files are added to PDF files created from Microsoft Access 2007, and we use fully defined paths, and the code works as follows, creating up to 10 PDF files per zip file:
Create zip code
Run this loop:
For Each ReportToRun
CreatePdf 'using DoCmd.OutputTo acOutputReport, "rptHame", acFormatPDF, strReportName
AddToZip
NextAny idea how to either fix this or the trap Can't create an output file error? Thanks
source
share