Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Excel sheets to PDF

Status
Not open for further replies.

gecko33

Technical User
Jan 20, 2011
1
US
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 afraid I can not help...
Can you help me saying what refferince do you use for the next declaration: 'pdfjob As PDFCreator.clsPDFCreator'?

Thanks in advance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top