Hello all,
I am hoping someone can help me with this. I am trying to print sheets in excel to PDF. I have done this before using code I found online, however I am needing the Macro to do more.
Currently the macro prints to PDF using the PDFCreator, but I need it to use the PDF-Xchange option, so I can set a password and create headers and footers automatically. I got the code working so that it prints using the PDF-Xchange, but I can't figure out how to automate the password, etc. In addition, I need the PDFs to auto-save to the sPDFpath.
Here is my current code:
_________________________________
Sub PDFit(sPDFName, sheetArray)
Dim sPDFPath As String
Sheets("Macro").Select
sPDFPath = Range("B2")
Dim pdfjob As PDFCreator.clsPDFCreator
Set pdfjob = New PDFCreator.clsPDFCreator
pdfjob.cStart
Application.Wait (Now + TimeValue("0:00:02"))
pdfjob.cClose
With pdfjob
If .cStart("/NoProcessingAtStartup", True) = 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
.cClearCache
End With
Sheets(sheetArray).PrintOut Copies:=1, ActivePrinter:="PDF-Xchange Conversion System"
Application.Wait (Now + TimeValue("0:00:01"))
'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
'Wait until the PDF file shows up then release the objects
pdfjob.cClose
Set pdfjob = Nothing
DoEvents
End Sub
_________________________
Thanks in advance
I am hoping someone can help me with this. I am trying to print sheets in excel to PDF. I have done this before using code I found online, however I am needing the Macro to do more.
Currently the macro prints to PDF using the PDFCreator, but I need it to use the PDF-Xchange option, so I can set a password and create headers and footers automatically. I got the code working so that it prints using the PDF-Xchange, but I can't figure out how to automate the password, etc. In addition, I need the PDFs to auto-save to the sPDFpath.
Here is my current code:
_________________________________
Sub PDFit(sPDFName, sheetArray)
Dim sPDFPath As String
Sheets("Macro").Select
sPDFPath = Range("B2")
Dim pdfjob As PDFCreator.clsPDFCreator
Set pdfjob = New PDFCreator.clsPDFCreator
pdfjob.cStart
Application.Wait (Now + TimeValue("0:00:02"))
pdfjob.cClose
With pdfjob
If .cStart("/NoProcessingAtStartup", True) = 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
.cClearCache
End With
Sheets(sheetArray).PrintOut Copies:=1, ActivePrinter:="PDF-Xchange Conversion System"
Application.Wait (Now + TimeValue("0:00:01"))
'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
'Wait until the PDF file shows up then release the objects
pdfjob.cClose
Set pdfjob = Nothing
DoEvents
End Sub
_________________________
Thanks in advance