Create a report PDF then email

eMail and PDF update v2007 is great

use Access 2007 and the PDF add-in. What used to be a huge chunk of code from Lebans can now be replaced by just 2 lines e.g.

DoCmd.SendObject acReport, strReportName, "PDFFormat(*.pdf)", strQuotationeMail, "", "", _
"Quotation from " & DLookup("([Company])", "Company Details"), DLookup("[emailbodytext]", "emailbodytext", "[ID]=1"), False, ""


emailbodytext is a table with one field that contains the eMail message. If you want to view/amend this before the above runs, just use this line too

DoCmd.OpenForm "F-emailbodytext", , , , , acDialog
 
Livening up this old thread yet again.

Using the example attached I have been able to create a pdf file but am unable to attach it to an email as I can't seem to extract the path that the pdf is saved. I have a folder on my PC called C:\Database Projects\Order System\Orders.mdb
When I create the PDF it saves it to the C:\Database Projects folder for some reason. Even if I move the Db to a different folder, the save location is still the same??

Am I able to direct where the PDF is saved, extract where the PDF is saved, or even better, direct the PDF to be saved in the same folder as the Db?

Cheers,
Dave
 
Using the example attached I have been able to create a pdf file but am unable to attach it to an email as I can't seem to extract the path that the pdf is saved.
Dave,
Did you mean to provide an attachment or are you referring to a previous post?

I'm pretty sure I had Lebans saving to a preffed location but I'll have to wait until I get home to check.

Chris
 
Thanks for the reply...

I'm using (in part) the following code to send the email, tagged on to the end of the "createPDF" sub

Set EmailApp = CreateObject("Outlook.Application")
Set EmailSend = EmailApp.CreateItem(olMailItem)

EmailSend.To = Me.EmailAddress
EmailSend.Subject = rptName
EmailSend.Attachments.Add (strPDFSaveLocation)
EmailSend.Display

I was having trouble detemining the location of the PDF to put in the strPDFSaveLocation, but have gotten around this by the following:

In the CreatePDF procedure there is a section that allows you to display the Save Dialog Box and select where you want to put the file. As I want this to be fully automated I altered this code to simply save the file to the current database folder using:

sOutFile = Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name))) & OutputPDFname & ".PDF"
strPDFsavelocation = sOutFile

strPDFsavelocation is declared globally, so I can pick it up from the sub on the form and wizz the email away.

Access (Microsoft) should have included this ability waaay before A2007

Dave
 
Hi
Sorry to drag up such an old post - but it has served me well so far!
I have used the Access 2k code for printing to a pdf (I am not interested in the emailing bit!). It runs but about 5 seconds after it creates the pdf Access gives me an error:
Action Failed
Macro Name: Macro1
Condition: True
Action Name: RunCode
Arguments: ConvertReportToPDF ("$WeeklySalesSummary", "", "WeeklySalesSummary.pdf", False, False, 0, "" , "" , 0 ,)

Can anybody help me with this? I'm not good at modules and classes. I just wanted to use the code to create 20 pdfs from various reports each week.

Thanks.
maccboy
 
Hmmm. Just noticed that Ted has written: 'Remember to change the TOOLS/REFERENCES to the Object Libraries in your version.' for the 2k version. I don't know what that means but it may be the cause of the error?

maccboy
 

Users who are viewing this thread

Back
Top Bottom