MS Access - VBA ~ Create "locked" PDF from report
Posted on 2011-10-04
Good Morning. Need a little help. I'm working on a project that creates multiple PDF's from a n MS Access report for distribution to conference attendees. It's basically a certificate that awards CEU's to medical staff for attending.
I've successfully create a routine to generate the PDF files for each attendee, which is working very well. However, after a brief sense of accomplishment, I realized that I wasn't quite finished. I need to 'lock' the PDF's so that the attendees cannot change them. Finding a solution has proved to be more difficult then I initially thought it would be.
I see two options. 1) Lock it during the creation phase. 2) Lock it as part of a post process that opens the PDF, assigns a password to lock it from editing, and then closes the document.
The code to 'create' the PDF's is pretty simple and works very well. Basically, three lines of code.
DoCmd.OpenReport "rptCEUCertificate", acViewPreview, , MyFilter
DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath & MyFilename, 0
DoCmd.Close acReport, "rptCEUCertificate"
Would appreciate thoughts on how to either assign the security at creation or to open each file and assign the permissions as a post process.