- Joined
- May 20, 2011
- Messages
- 1,518
- Reaction score
- 1
- Points
- 0
- Location
- Mississauga, Canada
- Excel Version(s)
- Excel 2016
I am trying to use Ken's Printing Worksheet to PDF file using PDFCreator found here: http://www.excelguru.ca/content.php?161
I am trying to use this in a loop.
What I am doing is running a query multiple times. Each time the query runs, I want to print to a new pdf. I keep getting the error"
"There was an error encountered. PDFCreator has been terminated. Please try again."
which is Ken's error control message.... and in the end it only prints the last query of the list to pdf.
My loop containing a call to Ken's code looks something like:
The PrintToPDF code I am trying to use is the Print a Single Worksheet to a PDF File version
Am I putting the call in the right place? Or is there something else I need to consider?
I am trying to use this in a loop.
What I am doing is running a query multiple times. Each time the query runs, I want to print to a new pdf. I keep getting the error"
"There was an error encountered. PDFCreator has been terminated. Please try again."
which is Ken's error control message.... and in the end it only prints the last query of the list to pdf.
My loop containing a call to Ken's code looks something like:
Code:
For i = 2 To x
PartID = Sheets("Sheet2").Range("A" & i)
With Sheets("Sheet1")
.Activate
sSql = "SELECT ... "
sSql = sSql & "FROM ... "
sSql = sSql & "WHERE ... "
With .Range("D6").QueryTable
.Connection = sConn
.Sql = sSql
.Refresh BackgroundQuery:=False
End With
[B] Call PrintToPDF_Early[/B]
End With
Next i
The PrintToPDF code I am trying to use is the Print a Single Worksheet to a PDF File version
Am I putting the call in the right place? Or is there something else I need to consider?