Excel VBA Example for PDFCreator password protected output?

I’ve spent several hours trying to get PDFCreator to work with excel VBA scripts. I did get the .com example for MS Word to work.

Specifically, I need to loop through all the sheets in a workbook, producing one PDF for each, which is encrypted and password protected.

I can do these things from the PDFCreator program interface, but it would take hours to do this for 100’s of sheets, and then to repeat when changes occur.

A simple script, that works with excel, to produce ONE encrypted, password protected PDF, under program control (file name, directory, sheet name, etc.) would be enough. I’ve scoured the Internet but cannot find one for version 3.x of PDFCreator. Any pointers/examples/suggestions are appreciated.

Thanks!
Pete A

Hi,

you can find a JS example for this here: http://docs.pdfforge.org/pdfcreator/3.0/en/pdfcreator/com-interface/user-manual/how-to/change-pdf-security-settings/

it should be easy to apply this to VBA, as all you need to do is set the settings for the job:

// Since we want to make our pdf more safe, we have to enable the security action first
 job.SetProfileSetting("PdfSettings.Security.Enabled", "true");

 // We set up the encryption level to medium
 job.SetProfileSetting("PdfSettings.Security.EncryptionLevel", "Medium128Bit");

 //Notice that in order to have a user password we have also to set the owner password
 //and additionally enable the RequireUserPassword property
 job.SetProfileSetting("PdfSettings.Security.OwnerPassword", "myOwnerPassword");

 //Require a user password to be able to view the PDF
 job.SetProfileSetting("PdfSettings.Security.RequireUserPassword", "true");

 //Now everyone who wants to open the converted file has to know the security password "myPassword"
 job.SetProfileSetting("PdfSettings.Security.UserPasswprd", "myPassword");

Best regards,

Robin