How to programmatically password PDFs?

Sum

Registered User.
Local time
Today, 06:36
Joined
Nov 19, 2012
Messages
17
I have some modules that I use to create and email spreadsheets and PDF reports. I've been able to password protect the spreadsheets in the modules, but how do I password protect PDFs? Anyone know of some VBA code I can use as a template?

Thanks
 
Anyone have any ideas? Thanks!
 
Here's an example of what I'm talking about:

DoCmd.OpenReport ReportName1, acViewPreview, , "[District]= '" & District & "'"

DoCmd.OutputTo acOutputReport, "", acFormatPDF, "" & FilePath & "District " & District & " - " & ReportName1 & ".pdf"

DoCmd.Close acReport, ReportName1

I use the above code to create a pdf in Access. Is there a way to password protect the pdf in the code?
 
Last edited:
Is there a way via the native Access user interface to produce a password protected PDF file? At first glance I see no support for such.

According to this page:

"DoCmd.OutputTo Method"
http://msdn.microsoft.com/en-us/library/office/bb238050(v=office.12).aspx

to get native PDF support you must add:

"Print, share, and protect files in the PDF and XPS file formats"
http://office.microsoft.com/en-us/h...the-pdf-and-xps-file-formats-HA010167527.aspx

The documentation for that add-on via VBA code is a bit sketchy at best. Syntax:

Code:
DoCmd.OutputTo acFormatPDF
seems to be the way. Searching Google for acFormatPDF password does not turn up much promising.
 
Last edited:
Thanks Michael, that's what I was afraid of.

I think what I'll do is create a batch processing file in Adobe to password protect the PDFs for me.

Now here's another question. How do I call the Adobe batch processing command from my Access VBA module?

I could just put a message box that pauses the code until I run the batch, but it would be nice to make it seamless.

Any thoughts?
 
google ShellAndWait

And waste at least half a day! I had to harvest ideas from about three different submissions to arrive at one that works completely! I should submit the results of my research to the code repository on this site. Trouble is, it will not be visible until moderation approval. I guess off to do that now...
 
Great to hear that you've already worked on ShellandWait, please let us know when the code has been added to the site and I'll check it out.
 
I did the post, awaiting moderation. Once approved I will try to remember to return and paste a link on this thread.
 

Users who are viewing this thread

Back
Top Bottom