gojets1721
Registered User.
- Local time
- Today, 08:06
- Joined
- Jun 11, 2019
- Messages
- 430
I'm using some simple code below to export an invoice and attach it to an email in outlook. The code also adds a default email subject and message.
When using this code, the attached invoice retains the same file name as the report name in Access. I was wondering if there's a way in VBA to rename the attached report to something different. I don't want to change the default naming format in Access (i.e. rptInvoice) but it would look a little bit better in Outlook if it was named something cleaner (i.e. Invoice, New Invoice, etc.)
Any suggestions?
When using this code, the attached invoice retains the same file name as the report name in Access. I was wondering if there's a way in VBA to rename the attached report to something different. I don't want to change the default naming format in Access (i.e. rptInvoice) but it would look a little bit better in Outlook if it was named something cleaner (i.e. Invoice, New Invoice, etc.)
Any suggestions?
Code:
Private Sub btnEmailInvoice_Click()
On Error GoTo btnEmailInvoice_Click_Err
DoCmd.RunCommand acCmdRefresh
DoCmd.SendObject acReport, "rptInvoice", "PDFFormat(*.pdf)", "", "", "", "Invoice", "Hello, your invoice is attached.", True, ""
btnEmailInvoice_Click_Exit:
Exit Sub
btnEmailInvoice_Click_Err:
If Err = 2501 Then
Else
' Report the error
MsgBox Err.Description, vbExclamation
End If
End Sub