Problems with PDFCreator

B

Brettjg

Hello there

I'm using the code below from Ken Puls to create a pdf from a multiple sheet
workbook. With some books it's just fine and with others it won't release at
the end. I've put Ken's fix about wait time and adjusted from 0 to 10 minutes
and just about everything in between, but no go. Does anyone have any ideas.

Alternatively, how can I get PDFCreator to add a page or two to an existing
file, or is this only available with PrimoPDF?

Thanks, Brett

CODE USED:
Option Explicit
Sub MULTISHEET_PDF() 'EARLY BINDING
Dim pdfjob As PDFCreator.clsPDFCreator
Dim sPDFName As String
Dim sPDFPath As String
Dim lSheet As Long
Dim lTtlSheets As Long

sPDFName = Range("pdf.name")
sPDFPath = ActiveWorkbook.Path & Application.PathSeparator
Set pdfjob = New PDFCreator.clsPDFCreator

If pdfjob.cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + vbOKOnly, "Error!"
Exit Sub
End If

With pdfjob
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0
.cClearCache
End With

lTtlSheets = Application.Sheets.Count
For lSheet = 1 To Application.Sheets.Count
On Error Resume Next
If Not IsEmpty(Application.Sheets(lSheet).UsedRange) Then
Application.Sheets(lSheet).PrintOut copies:=1,
ActivePrinter:="PDFCreator"
Else
lTtlSheets = lTtlSheets - 1
End If
On Error GoTo 0
Next lSheet

Do Until pdfjob.cCountOfPrintjobs = lTtlSheets
DoEvents
Loop

With pdfjob
.cCombineAll
.cPrinterStop = False
End With

Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
Application.Wait Now + TimeValue("0:0:10")

pdfjob.cClose
Set pdfjob = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top