How is my PDF filename generated?

Sketchin

Registered User.
Local time
Today, 15:00
Joined
Dec 20, 2011
Messages
580
I have this code:
Code:
Private Sub CmdEmailPDF_Click()
On Error GoTo CmdEmailPDF_Click_Err
Dim Subject As String
   
   Subject = Me.Text38 & "-" & "Tecterra Invoice" & ".pdf"
    
    Me.ChkInvoicePaid = True
    DoCmd.OpenForm "frmrptCurrentRecordInvoice", acPreview, , "[InvoiceID]= forms!frmInvoicing![InvoiceID]"
    DoCmd.SendObject acForm, "frmrptCurrentRecordInvoice", "PDFFormat(*.pdf)", "", "", "", Subject, "Hello,  attached you will find a PDF of your current TECTERRA invoice.", True, ""
    DoCmd.Close
    
CmdEmailPDF_Click_Exit:
    Exit Sub
CmdEmailPDF_Click_Err:
    MsgBox Error$
    Resume CmdEmailPDF_Click_Exit
End Sub

When I hit the command button, an outlook email is created with a pdf called Invoice.PDF. Problem is, I want to change the name of the generated pdf file but I have no idea where that is being created!

Feel a bit foolish that I dont even know how my code works, but it was a long time ago that I created this mechanism.
 
When you use SendObject, it uses the report name as the pdf name. If you want to change the name you will have to use DoCmd.OutputTo and give it the dynamic file name there. Then you will have to send it in another way (if you have Outlook you can use the Outlook object model).


EDIT: Oh, and you can use the constant acFormatPDF instead of the longer thing you are using to specify the format. It also works in OutputTo.
 
Thanks bob!
 

Users who are viewing this thread

Back
Top Bottom