What I would do is process one file at a time without sending the email, and check to see if the file is being updated correctly each time. If so, it would seem to be a problem with sending the email with the attachment.
I have tried exactly that by inserting the addressee name into the file name and saving it. When I do that on the target machine each generated file has the correct info and is correctly attached to the email. I could do that always, but that would mean about 400 files being created that I would then have to remove when the process was completed. It was to avoid that extra step that I was giving each one the same file name and overwriting it for each for recipient, so I only had one output file that could just remain. However if I can't solve this then plan B would be individual files.
That's not really what I was suggesting. It sounds like the problem is not related to Acrobat and you should be able to tell if you overwrite the file each time and confirm that it's changed each time by opening it. If it is correctly overwritten each time when saved by Acrobat, it would seem to indicate that the problem is elsewhere.
OK I understand. I'll give that a go. Probably won't be till next week. Thanks for the advice. I'll report back.
This takes a bit of explaining, so bear with me…
On the target machine I set the emails to display rather than send, and selected a small subset of the database. When I ran the process without interruption, each email had the personalisation from the first record selected. However, if I put in break points to track what was happening, the process worked correctly, i.e. each email had a the correct individualised PDF, which makes it look like some sort of timing issue. I tried putting in DoEvents in the code at what seemed like appropriate places to let things “catch up”, but that had no effect. I also tried a 5 second delay loop between records – still no good.
Then I tried to delete the updated PDF after each record was processed, but that gave me a “permission denied” error with a code of 70, which can mean trying to access a read-only or locked file. I set the file attributes to normal, and still got the error, so I assume the file is locked and hasn’t been released by the time the next record is to be processed. Still looks like a timing issue.
The principal differences between the environments are Win10 vs Win7, fast machine vs slow(ish) machine and Acrobat 9 vs Acrobat 7.
Back home I tried running the app on Win7 on a fast machine and on Win 10 on a slow machine, all with Acrobat 9. Everything worked OK. I don’t have access to Acrobat 7 or to Win7 on a slow machine.
So it is still looking to me like an Acrobat 9 vs Acrobat 7 issue.
Is there a programmatic way I can force a lock to be released?
Do you have any other ideas?