ACG Soft - "PDF & Mail Class Library" - Email PDF from Access 2k3

J

JvdWal

Hi,

I've been trying the PDF & Mail Class Library from ACG Soft
in combination with Northwind-2k3 style of db. Can someone help
me with the error which is popping up: (which I cant get solved..)

I'm trying to send a report in PDF-format with a unique QuotationID to
one specific customer by Email. >> Button in a form >> quotation-report
and a "filter and printfilter"- query..

MS Visual Basic Compile Error:
"Method or data member not found"
With the next line highlighted in the code:
.lngReturn = .Result


-------------Here is the code----------------
Private Sub Command33_Click()
On Error GoTo Err_Command33_Click

Dim objPDF As PDFClass
Dim objMail As MailClass
Dim strCurFileName As String

Dim strBaseFileLocation As String
Dim lngReturn As Long
Dim rsReports As Recordset '<- DAO recordset

'Comment out the line above and uncomment the two lines below when using
ADO in A2000 and 2002
'Dim conn As ADODB.Connection '<- ADO
'Dim rsReports As New ADODB.Recordset '<- ADO
Const MAIL_SYS_CDO = -1
Const RECIPIENT_TO = 1
Const PDFENGINE_WIN2PDF = 3


Set rsReports = CurrentDb.OpenRecordset("Select DISTINCT OfferteID,
emailadres from qryOfferteformGEN1PrintFILTER", dbOpenSnapshot) '<- DAO
recordset
'Comment out the line above and uncomment the two lines below when using
with ADO in A2000 and 2002
'Set conn = CurrentProject.Connection '<- ADO
'rsReports.Open "Select DISTINCT OfferteID, emailadres from
qryOfferteformGEN1PRINT", conn, adOpenStatic, adReadOnly '<- ADO
strBaseFileLocation = "C:\"
Set objPDF = New PDFClass
Set objMail = New MailClass

Do Until rsReports.EOF 'End of File

strCurFileName = strBaseFileLocation & "Orders For " &
rsReports!OfferteID & ".pdf"
With objPDF
.PDFEngine = PDFENGINE_WIN2PDF
.ReportName = "Offerte-per-Email"
.ReportWhere = "[OfferteID] = " & rsReports!OfferteID
.OutputFile = strCurFileName
.PrintImage
.lngReturn = .Result
End With

If lngReturn = True Then '<- PDF was output successfully
With objMail

..MsgSubject = "Current Invoice"
.MsgBodyText = "Attached is the current invoice for your
account in PDF format."
.RecipientAdd rsReports!KlantID, rsReports!emailadres, ,
RECIPIENT_TO, False
.AttachmentAdd strCurFileName, "Current Account Invoice.pdf"
.MsgSaveCopy = True
.SendMail MAIL_SYS_CDO
.RecipientsReset '<- get ready for the next mail item
.AttachmentsReset

End With
Else
MsgBox "Error!"
End If
rsReports.MoveNext
Loop

rsReports.Close
Set objPDF = Nothing
Set objMail = Nothing

Exit_Command33_Click:
Exit Sub

Err_Command33_Click:
MsgBox Err.Description
Resume Exit_Command33_Click

End Sub
-------------END of the code----------------

Whats wrong,... I've been trying, trying and trying...?!?
I heve been commenting out as well the ADO/DAO lines to 2000/2002,
then I get an error in "Dim conn As ADODB.Connection"..

(What my Access knowledge concerns, not a newbie, but have not much
VB programmskils either, more reading it a bit and cut&paste :-(
I'm using Access 2003 btw.

Hope someone can help me with this..
 
L

Lyle Fairfield

JvdWal said:
Hi,

I've been trying the PDF & Mail Class Library from ACG Soft
in combination with Northwind-2k3 style of db. Can someone help
me with the error which is popping up: (which I cant get solved..)

I'm trying to send a report in PDF-format with a unique QuotationID to
one specific customer by Email. >> Button in a form >> quotation-report
and a "filter and printfilter"- query..

MS Visual Basic Compile Error:
"Method or data member not found"
With the next line highlighted in the code:
.lngReturn = .Result

lngReturn is a variable and not a member of objPDF.

So this may be more successful:

lngReturn = .Result
 
J

JvdWal

Lyle said:
lngReturn is a variable and not a member of objPDF.

So this may be more successful:

lngReturn = .Result

Hi, thanks for the quick reaction!

I changed the line into your suggestion: the tail of code is now like
this, but now with a highlighted compile error on ".MsgSubject":
- I kept the caption in the report empty, if it has something to do with
it..)
- configured Outlook to send the emails. (dont know if there support for
Mozilla.. ;-)

---------------tail of the code------------
strCurFileName = strBaseFileLocation & "Orders For " &
rsReports!OfferteID & ".pdf"
With objPDF
.PDFEngine = PDFENGINE_WIN2PDF
.ReportName = "Offerte-per-Email"
.ReportWhere = "[OfferteID] = " & rsReports!OfferteID
.OutputFile = strCurFileName
.PrintImage
lngReturn = .Result
End With

If lngReturn = True Then '<- PDF was output successfully
With objMail

..MsgSubject = "Current Invoice"
.MsgBodyText = "Attached is the current invoice for your
account in PDF format."
.RecipientAdd rsReports!KlantID, rsReports!emailadres, ,
RECIPIENT_TO, False
.AttachmentAdd strCurFileName, "Current Account Invoice.pdf"
.MsgSaveCopy = True
.SendMail MAIL_SYS_CDO
.RecipientsReset '<- get ready for the next mail item
.AttachmentsReset

End With
Else
MsgBox "Error!"
End If
rsReports.MoveNext
Loop

rsReports.Close
Set objPDF = Nothing
Set objMail = Nothing

Exit_Command33_Click:
Exit Sub

Err_Command33_Click:
MsgBox Err.Description
Resume Exit_Command33_Click

End Sub
---------------end code------------
 
T

Tony Gardner

In Access 97 the requirement is .MsgSubjectText. See if that works.
Tony Gardner

JvdWal said:
Lyle said:
lngReturn is a variable and not a member of objPDF.

So this may be more successful:

lngReturn = .Result

Hi, thanks for the quick reaction!

I changed the line into your suggestion: the tail of code is now like
this, but now with a highlighted compile error on ".MsgSubject":
- I kept the caption in the report empty, if it has something to do with
it..)
- configured Outlook to send the emails. (dont know if there support for
Mozilla.. ;-)

---------------tail of the code------------
strCurFileName = strBaseFileLocation & "Orders For " &
rsReports!OfferteID & ".pdf"
With objPDF
.PDFEngine = PDFENGINE_WIN2PDF
.ReportName = "Offerte-per-Email"
.ReportWhere = "[OfferteID] = " & rsReports!OfferteID
.OutputFile = strCurFileName
.PrintImage
lngReturn = .Result
End With

If lngReturn = True Then '<- PDF was output successfully
With objMail

.MsgSubject = "Current Invoice"
.MsgBodyText = "Attached is the current invoice for your
account in PDF format."
.RecipientAdd rsReports!KlantID, rsReports!emailadres, ,
RECIPIENT_TO, False
.AttachmentAdd strCurFileName, "Current Account Invoice.pdf"
.MsgSaveCopy = True
.SendMail MAIL_SYS_CDO
.RecipientsReset '<- get ready for the next mail item
.AttachmentsReset

End With
Else
MsgBox "Error!"
End If
rsReports.MoveNext
Loop

rsReports.Close
Set objPDF = Nothing
Set objMail = Nothing

Exit_Command33_Click:
Exit Sub

Err_Command33_Click:
MsgBox Err.Description
Resume Exit_Command33_Click

End Sub
---------------end code------------
 
J

JvdWal

Tony said:
In Access 97 the requirement is .MsgSubjectText. See if that works.
Tony Gardner

Hi,

Its working now, with this one and some other small changes..
Tnx!
 

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