Below is my code for V4, using IPXCControlEx. With VB breakpoints, I have verified that OnFileSaved is getting called, and the lpszFileName parameter is correct. But for some reason OnStartDoc is never getting called, so the reports are coming out as separate files. Any thoughts as to why? I'm running Excel 2003 under Windows 2000, if it matters.
Code: Select all
Option Explicit
Dim myFactory As New PXCComLib.CPXCControlEx
Dim myFileName As String
Dim myFirstJob As Boolean
Dim myLastJob As Boolean
Dim WithEvents myPrinter As PXCComLib.CPXCPrinter
Private Sub Class_Initialize()
Set myPrinter = myFactory.Printer("", "TempPdfPrinter", "", "")
End Sub
Private Sub Class_Terminate()
Set myPrinter = Nothing
End Sub
Private Sub myPrinter_OnFileSaved(ByVal JobID As Long, ByVal lpszFileName As String)
myFileName = lpszFileName
End Sub
Private Sub myPrinter_OnStartDoc(ByVal JobID As Long, ByVal lpszDocName As String, ByVal lpszAppName As String)
If myFirstJob Then
myPrinter.Option("Save.ShowSaveDialog") = True
myPrinter.Option("Save.WhenExists") = 0 'ShowWarning
myFileName = ""
Else
myPrinter.Option("Save.ShowSaveDialog") = False
myPrinter.Option("Save.File") = myFileName
myPrinter.Option("Save.WhenExists") = 3 'Append
End If
End Sub
Public Sub SetFirstLast(bFirst As Boolean, bLast As Boolean)
myFirstJob = bFirst
myLastJob = bLast
End Sub