darls15
asked on
Error when running macro that merges and saves MSWord docs as PDFs
Hi Experts
I've found some very useful macro code which helps me to automatically merge and save individual PDFs documents.
I've associated the macro with a button in a MSWord document. It automatically opens my MSWord document (which is a certificate) that contains merge fields linking it to a MSAccess query and then creates individucal MSWord documents for each records and finally PDFs them in the same process.
Everything works as I would except it to and all PDFs get created, however I'm receiving this error at the end of the process, "This file is in use by another application or user."
Can anyone help with with why this happens? I have attached a text document with the code.
Thanks in advance
darls15
MergePDFsCode.txt
I've found some very useful macro code which helps me to automatically merge and save individual PDFs documents.
I've associated the macro with a button in a MSWord document. It automatically opens my MSWord document (which is a certificate) that contains merge fields linking it to a MSAccess query and then creates individucal MSWord documents for each records and finally PDFs them in the same process.
Everything works as I would except it to and all PDFs get created, however I'm receiving this error at the end of the process, "This file is in use by another application or user."
Can anyone help with with why this happens? I have attached a text document with the code.
Thanks in advance
darls15
MergePDFsCode.txt
ASKER
Hi Graham
First of all, thank you for the original macro, this is going to help me a lot!
I tried your amended ConvertWordsToPdfs macro and it works very well and all PDFs are created without error.
I then tried your second macro as I don't need to keep the copies of the Word documents however it only created the Word versions and stopped.
Can you please help?
Thanks
darls15
First of all, thank you for the original macro, this is going to help me a lot!
I tried your amended ConvertWordsToPdfs macro and it works very well and all PDFs are created without error.
I then tried your second macro as I don't need to keep the copies of the Word documents however it only created the Word versions and stopped.
Can you please help?
Thanks
darls15
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is brilliant & works perfectly! Thanks for all your help Graham.
Have a great day.
darls15
Have a great day.
darls15
However the second one tries to open every file in the folder and create a PDF from it, even if it is already a PDF. The rename from .doc to .pdf won't do anything, so you will be trying to export to a file that is already open. This version filters out the files that aren't Word documents.
Open in new window
If you don't need to have Word document copies you can export in the first macro:Open in new window