Set Password In VBA

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
askolits
Posts: 2
Joined: Thu Oct 16 2003

Set Password In VBA

Post by askolits »

I have an old version of PDF Converter (2.1). Always works fine, but I want to put a password on the document.

I found another Topic in this message board and it said to do the following.

pdf.Permissions = -64 + 4 '+ 16 + 32
pdf.FileNameOptionsEx = 1 + 2 + 256
pdf.OwnerPassword = "password"
pdf.UserPassword = "clientpassword"
pdf.SetDefaultConfig

I added this to my code. The code doesn't produce an error and the file is created.
Yet, it doesn't ask me for a password when opening.

Here's is a code snippet.


'****************************************************

pdf.DriverInit strPDF_PRINTER_NAME ' strPDFPrinterName is declared as the name of the existing printer

'this is to be called after PDFDriverInit / DriverInit for Developer version 2.1
pdf.EnablePrinter LicensedTo, ActivationCode

'Set this printer as default
pdf.SetDefaultPrinter

' set output PDF file name
pdf.DefaultFileName = "C:\Test.pdf"
'***NEW CODE FOR PASSWORD PROTECTION
pdf.Permissions = -64 + 4 '+ 16 + 32
pdf.FileNameOptionsEx = 1 + 2 + 256
pdf.OwnerPassword = "password"
pdf.UserPassword = "clientpassword"
pdf.SetDefaultConfig
'***
pdf.FileNameOptionsEx = NoPrompt + UseFileName
' 'Enable the printer before each printout for the Developer version 2.1
pdf.EnablePrinter LicensedTo, ActivationCode

' print first report
DoCmd.OpenReport strReportname, acViewNormal

pdf.RestoreDefaultPrinter
NeedToRestoreDefault = False
' Reset options to zero
pdf.FileNameOptions = 0
David
Amyuni Team
Posts: 89
Joined: Mon Dec 18 2006

Re: Set Password In VBA

Post by David »

Hello

Your code snippet is correct for encrypting a document. You can find more information on encyption at the following online documentation:
http://amyuni.com/WebHelp/Merged_CDI_Do ... ssions.htm

In versions before v3.0 the PDF Converter developer license was split into a standard license or a professional license.

To use the advanced functions like encryption in earlier versions (like v2.1), you required the professional license. I suspect that you have that standard license which does not have the encryption option enabled.

Hope that helps
Amyuni Custom Development
Do you need a specific PDF solution? Are you looking for expertise that will enable you to start or complete a PDF integration project?
http://www.amyuni.com/en/company/services.php
askolits2
Posts: 2
Joined: Thu Aug 06 2009

Re: Set Password In VBA

Post by askolits2 »

Sorry it took so long to respond. I had to change my eamil and it took a while before the forum manager got back to me.

Yes, I do have a full professional version of this:

"Developer License of the Amyuni PDF Converter Professional for Windows"

So should I be having this problem?

John
askolits2
Posts: 2
Joined: Thu Aug 06 2009

Re: Set Password In VBA - RESOLVED

Post by askolits2 »

I think the problem was were I placed the activation line. "pdf.EnablePrinter LicensedTo, ActivationCode"
I made sure it was after the "pdf.SetDefaultConfig" line and I think that fixed it.
Thanks,

John
Post Reply