Good afternoon. I am hoping someone can help me out. I have a new job that requires me to run a VBA Macro. The macro is supposed to create a PDF document from an Excel Spreadsheet and encode it with a password. When I run the macro I get an "Run time error "429": ActiveX component can't create object." When I go to debug, the macro highlights the line
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator").
I do have the newest version of PDF creator as well as PDF architect installed on my computer. I have no idea what this error requires I do.
I am copying all of the code below. I would appreciate any and all help. Thank You.
Sub PrintToPDF(StrR As String, StrEE As String, StrPass As String, StrMstPass As String)
Dim pdfjob As Object
Dim sPDFName As String
Dim sPDFPath As String
Dim sMasterPass As String
Dim sUserPass As String
'/// Change the output file name here! ///
sPDFName = StrR & "-" & StrEE
sPDFPath = "C:\Test\test"
sMasterPass = StrMstPass
sUserPass = StrPass
'Check if worksheet is empty and exit if so
If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + _
vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
'The following are required to set security of any kind
.cOption("PDFUseSecurity") = 1
.cOption("PDFOwnerPass") = 1
.cOption("PDFOwnerPasswordString") = sMasterPass
'To set individual security options
.cOption("PDFDisallowCopy") = 0
.cOption("PDFDisallowModifyContents") = 1
.cOption("PDFDisallowPrinting") = 0
'To force a user to enter a password before opening
.cOption("PDFUserPass") = 1
.cOption("PDFUserPasswordString") = sUserPass
'To change to High encryption
'.cOption("PDFHighEncryption") = 1
.cClearCache
End With
'Print the document to PDF
ActiveSheet.PrintOut copies:=1, ActivePrinter:="PDFCreator"
'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
pdfjob.cClose:
Set pdfjob = Nothing
End Sub
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator").
I do have the newest version of PDF creator as well as PDF architect installed on my computer. I have no idea what this error requires I do.
I am copying all of the code below. I would appreciate any and all help. Thank You.
Sub PrintToPDF(StrR As String, StrEE As String, StrPass As String, StrMstPass As String)
Dim pdfjob As Object
Dim sPDFName As String
Dim sPDFPath As String
Dim sMasterPass As String
Dim sUserPass As String
'/// Change the output file name here! ///
sPDFName = StrR & "-" & StrEE
sPDFPath = "C:\Test\test"
sMasterPass = StrMstPass
sUserPass = StrPass
'Check if worksheet is empty and exit if so
If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + _
vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
'The following are required to set security of any kind
.cOption("PDFUseSecurity") = 1
.cOption("PDFOwnerPass") = 1
.cOption("PDFOwnerPasswordString") = sMasterPass
'To set individual security options
.cOption("PDFDisallowCopy") = 0
.cOption("PDFDisallowModifyContents") = 1
.cOption("PDFDisallowPrinting") = 0
'To force a user to enter a password before opening
.cOption("PDFUserPass") = 1
.cOption("PDFUserPasswordString") = sUserPass
'To change to High encryption
'.cOption("PDFHighEncryption") = 1
.cClearCache
End With
'Print the document to PDF
ActiveSheet.PrintOut copies:=1, ActivePrinter:="PDFCreator"
'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
pdfjob.cClose:
Set pdfjob = Nothing
End Sub