First off, bear with me; I've just started to learn VBA and this is my first post on this site. My question could be extremely basic, but I haven't been able to find anything via the internet that fits my needs exactly.
I need a way to save a report to a specific path after I have printed it as a PDF, so that I can send it as an email attachment. The idea is that an associate would be able to press a button and the report would print to PDf and send. I have the printing and the email code, but where I'm stuck is that I don't know how to save the report automatically to a path after using the PDF Printer. Right now it prints but then opens a "Save As" dialogue box. I'd like it to print and then save itself to a path.
This is the code I'm using at the moment to print the report:
Expand|Select|Wrap|Line Numbers
- Private Sub Command0_Click()
- Dim defPrinter As String, NewPrinter As Printer
- defPrinter = Application.Printer.DeviceName
- Set NewPrinter = Application.Printers("Nationwide PDF Printer")
- Set Application.Printer = NewPrinter
- DoCmd.OpenReport "Weekly Application Status Update", acViewNormal
- DoCmd.Close acReport, "Weekly Application Status Update", acSaveNo
- Set NewPrinter = Application.Printers(defPrinter)
- Set Application.Printer = NewPrinter
- End Sub