1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
Private Sub Email_Click()
Dim sExistingReportName As String
Dim sAttachmentName As String
'Input variables
sExistingReportName = "E_Nom" 'Name of the Access report Object to send
sAttachmentName = "Demande" 'Name to be used for the attachment in the e-mail
'The code to make it happen
DoCmd.OpenReport sExistingReportName, acViewPreview, , "N°=" & Me.ID, acHidden
Reports(sExistingReportName).Caption = sAttachmentName 'by changing the report caption
'you effectively change the name
'used for the attachment in the
'.SendObject method
Shell "explorer C:\Temp\", vbNormalFocus 'ouvre dossier
On Error GoTo err
DoCmd.SendObject acSendReport, sExistingReportName, _
"PDF", "...@...", , , "Demande" & Reports!E_Nom.[Article], _
""
DoCmd.Close acReport, sExistingReportName
fin:
Exit Sub
err:
If err.Number <> 2501 Then err.Raise err.Number, , err.Description
Resume fin
End If
End Sub |
Partager