I'm trying to
1- Export a report as pdf
2- zip and password protect the pdf,
3- Attach it to a mail
4- Send it to a customer.
If I step into the code with F8, everything is just fine. Not even a single error. The task is done.
But when I run the same code normally, the line that adds the attachment to the mail throws the following error.
I assumed the zip file is not ready. Added the following to the end of the function that creates the zip file:
now the error is changed as following:
If I click Debug button the following line is highlited:
From there, If I use either F5 or F8 the code continues and the file will be attached.
Can anyone advice what causes this behavior and how I can bypass this error?
And why DoEvents loop is not enough to wait for the file being ready to be added?
thank you.
1- Export a report as pdf
2- zip and password protect the pdf,
3- Attach it to a mail
4- Send it to a customer.
If I step into the code with F8, everything is just fine. Not even a single error. The task is done.
But when I run the same code normally, the line that adds the attachment to the mail throws the following error.
I assumed the zip file is not ready. Added the following to the end of the function that creates the zip file:
Code:
Do Until Len(Dir(zippedFileName)) > 0
DoEvents
Loop
now the error is changed as following:
If I click Debug button the following line is highlited:
Code:
.Attachments.Add zippedFileName
From there, If I use either F5 or F8 the code continues and the file will be attached.
Can anyone advice what causes this behavior and how I can bypass this error?
And why DoEvents loop is not enough to wait for the file being ready to be added?
thank you.
Last edited: