With events and reports

If you are a VB developer and have questions about using our products from VB, here is the place to post them.
Post Reply
alwaysbusy
Posts: 1
Joined: Thu May 13 2004

With events and reports

Post by alwaysbusy »

Hi All,

I'm having some problems getting the PDF Events in Access when I print a report. I've done it successfully when I print a Word document. I get the events like 'pdf_EndDocPost'.

When doing exactly the same, but now printing a report, I do not get this event. Im using cdintf210.dll.

This is an extract of the code I use:

Declaration:

Private WithEvents pdf As CDIntfEx.CDIntfEx
Private NotEndDoc As Boolean

In a command button:

Set pdf = New CDIntfEx.CDIntfEx
pdf.DriverInit PrinterName

FileName = TempFolder & FileName
pdf.SetDefaultPrinter
prv_DeleteTempFile FileName & ".pdf"
pdf.DefaultFileName = FileName & ".pdf"
pdf.FileNameOptionsEx = NoPrompt + UseFileName + BroadcastMessages '+ EnableWatermarks
pdf.CaptureEvents True
pdf.EnablePrinter LicensedTo, ActivationCode

DoCmd.OpenReport stDocName, acViewNormal, , Where_str


NotEndDoc = True

While NotEndDoc
DoEvents
Wend

pdf.CaptureEvents False
pdf.RestoreDefaultPrinter

pdf.FileNameOptions = 0
pdf.DriverEnd
Set pdf = Nothing
SendEmailWithAttachmentTo FileName & ".pdf", cmbEmail.Column(1), Me.TitelRapport

The Event:

Private Sub pdf_EndDocPost(ByVal JobID As Long, ByVal hDC As Long)
NotEndDoc = False
End Sub

Any clues? Thx!
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Please send this request to support@amyuni.com to check it.

Thanks.
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,

The PDF Converter is also available as non-visible activex control and using the control in this manner you will be able to retrieve the message being generated by the PDF Converter.

In order to successfully do this, click on the More Control icon and drag the "Common Driver Interface Control" on to your form.

Next, in your code you will need to create an object of type CDIntfEx and assign this object the control on your form. The activeX control fires different events and you will be able to process these events. I have added a code snippet to illustrate this.

Hope this helps?

'Declare object of type CDIntfEx
Public cdi As CDIntfEx.CDIntfEx

'Declare printer
Const PDFprinter = "Amyuni PDF Converter"

Private Sub Form_Load()
'CDIntfEx0 is name of ActiveX control on form
Set cdi = CDIntfEx0.Object
cdi.DriverInit (PDFprinter)
cdi.DefaultFileName = "c:\temp\access_3.pdf"
cdi.SetDefaultPrinter

'No_prompt + User_filename + BroadCastMessages
cdi.FileNameOptions = 35
cdi.CaptureEvents (1)
End Sub

Private Sub Command1_Click()
'Print something
cdi.EnablePrinter strLicenseTo, strActivationCode
DoCmd.OpenReport "PDFFiles", acViewNormal
End Sub


'Event fired by ActiveX Control
Private Sub CDIntfEx0_StartDocPre()
MsgBox "in StartDocPre"
End Sub


Thanks
Post Reply