Hi all - I am attempting to send a PDF via a DoCmd.SendObject command. One of the requirements is to have the PDF attachment named after a variable field in the report. The only way I have been able to get this to work is through a DoCmd.OpenReport and name the Window what I need the file name to be named.
The problem exists when the print preview window does not close. If I run another report, the original print preview window is not replaced and the wrong report is sent with the SendObject command. The work around for this is to manually close the print preview window.
I have tried automatically closing it after the SendObject command with a DoCmd.Close command, but I am unable to close it that way.
I am looking for either one of two solutions:
1) a more elegant way of sending a "named" PDF attachment via SendObject or
2) a way to automatically close the Print Preview window.
Thanks...
Code:
DoCmd.OpenReport "rpt_Certificate", acViewPreview, , , acWindowNormal
DoCmd.SendObject acSendReport, "rpt_Certificate", acFormatPDF, MailTo, _
MailCC, , Subject, Body, True
DoCmd.Close acReport, [FTSOCertNumber]