Thread View: be.comp.programming
1 messages
1 total messages
Started by bart van deun
Tue, 20 Apr 2004 07:59
Wie kan mij helpen: pdf omzetten onder access vba en dan mailen
Author: bart van deun
Date: Tue, 20 Apr 2004 07:59
Date: Tue, 20 Apr 2004 07:59
72 lines
3266 bytes
3266 bytes
Ik zit met een probleemke: met deze tool: http://ourworld.compuserve.com/homepages/attac-cg/ kan ik onder access vba met library's PDF files maken van reports en verzenden via email, dit allemaal op de achtergrond. Nu zou ik dit willen inbouwen in mijn access crm systeem maar de code die ik meekreeg, daar kom ik niet goed aan uit, door gebrek aan vba ervaring... Kan iemand mij zeggen wat te doen? dit is de code om verschillende email adressen aan te doen met een omgezette pdf file (van de software leverancier): (ik krijg bvb. als foutmelding dat adReadOnly een niet geregistreerde variabel is...) Dim objPDF as PDFClass Dim objMail as MailClass Dim strCurFileName as String Dim strBaseFileLocation as String Dim lngReturn as Long Dim conn as ADODB.Connection '<- ADO Dim rsReports as New ADODB.Recordset '<- ADO Const MAIL_SYS_CDO = -1 Const RECIPIENT_TO = 1 Const PDFENGINE_PDFWRITER =1 Set conn = CurrentProject.Connection '<- ADO rsReports.Open "Select DISTINCT CustomerID, EMail from qryRptOrders", conn, adOpenStatic, adReadOnly '<- ADO strBaseFileLocation = "C:\Temp\" Set objPDF = New PDFClass Set objMail = New MailClass Do Until rsReports.EOF 'End of File strCurFileName = strBaseFileLocation & "Orders For " & rsReports!CustomerID & ".pdf" With objPDF .PDFEngine = PDFENGINE_PDFWRITER .ReportName = "rptOrders" .ReportWhere = "[CustomerID] = " & rsReports!CustomerID .OutputFile = strCurFileName .PrintImage .lngReturn = .Result End With If lngReturn = True Then <- PDF was output successfully With objMail .MsgSubjectText = "Current Invoice" .MsgBodyText = "Attached is the current invoice for your account in PDF format." .RecipientAdd rsReports!CustomerID, rsReports!Email, ,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 'Copyright � 1997-2003 ATTAC Consulting Group
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads