Excel VBA Marco doesn’t work

Hello all,

I used to use the excel vba code below; however it doesn’t work in v3.4.0 pdfcreator
How should I amend the code to run the pdfcreator through excel vba.
Thanks in advance :smiley:

Sub PrintToPDF(sPDFPath, sPDFName, sMasterPass)

' Designed for late bind, no references req'd
Dim pdfjob As Object
Dim bRestart As Boolean

Do
Sleep 1000
bRestart = False
Set pdfjob = CreateObject("PDFCreator.PDFCreatorObj")
If pdfjob.cStart("/NoProcessingAtStartup") = False Then
    'PDF Creator is already running.  Kill the existing process
    Shell "taskkill /f /im PDFCreator.exe", vbHide
    DoEvents
    Set pdfjob = Nothing
    bRestart = True
End If
Loop Until bRestart = False



'Set all defaults
With pdfjob
    .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") = 1
    .cOption("PDFDisallowModifyContents") = 1
    .cOption("PDFDisallowPrinting") = 1

    'To force a user to enter a password before opening
    .cOption("PDFUserPass") = 1
    .cOption("PDFUserPasswordString") = sMasterPass
    'To change to High encryption
    .cOption("PDFHighEncryption") = 1

    'Get ready for the print job
    .cClearCache
End With

'Delete the PDF if it already exists
If Dir(sPDFPath & sPDFName & ".pdf") = sPDFName & ".pdf" Then Kill (sPDFPath & sPDFName & ".pdf")

'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 the file shows up before closing PDF Creator
Do
    DoEvents
Loop Until Dir(sPDFPath & sPDFName & ".pdf") = sPDFName + ".pdf"
Set pdfjob = Nothing

End Sub