I found code to print multiple excel sheets into 1 pdf. The code starts with:
Dim pdfjob As PDFCreator.clsPDFCreator
I get an error link "user defined filetype is nog defined"(translated from dutch).
What does this error mean?
This is the whole script:
Sub test()
Dim mypdfjob As PDFCreator.clsPDFCreator
Dim sPDFName As String
Dim sPDFPath As String
Dim file_name, temp_name, temp_name2 As String
Dim tempstr1, tempstr2, tempstr3 As String
tempstr1 = Range("a3").Value
tempstr2 = Range("b3").Value
tempstr3 = Range("j3").Value
temp_name = "c:\\CheckLists\\" & tempstr1 & "\\" & tempstr2 & " to " & tempstr3
temp_name2 = Replace(temp_name, "/", "-")
file_name = temp_name2
'/// Change the output file name here! ///
sPDFName = tempstr1 & ".pdf"
sPDFPath = file_name
'Check if worksheet is empty and exit if so
If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
Set pdfjob = New 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
.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