I have some code where the end user can automatically send out a report through MS outlook, by clicking a command button. However I was wandering, if instead of automatically sending the E-mail, can you get the code to open outlook if the user needs to send any additional attachments. Below is the code I am using.
Public Sub ExportGraph()
On Error GoTo ExportGraph_Err
Dim strErrMsg As String 'For Error Handling
Dim oleGrf As Object
Dim strFileName As String
Dim strFilter As String
Dim lngFlags As Long
Dim olApp As New Outlook.Application
Dim olNameSpace As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Set olNameSpace = olApp.GetNamespace("MAPI"
Set olMail = olApp.CreateItem(olMailItem)
DoCmd.OpenReport "InitialReportForm", acViewPreview
Set oleGrf = Reports("InitialReportForm"
strFileName = ahtCommonFileOpenSave(Flags:=lngFlags, InitialDir:="C:\", _
Filter:="Rich Text Format Files (*.rtf)", FilterIndex:=1, DefaultExt:="rtf", FileName:="MyReport", _
DialogTitle:="Save the Report", OpenFile:=False)
DoCmd.OutputTo acOutputReport, "InitialReportForm", _
acFormatRTF, strFileName, False
MsgBox vbCrLf & "The Report " & strFileName & " has been exported", _
vbInformation + vbOKOnly, "Report exported :"
With olMail
.To = "aroberts@guidemail.com"
.Subject = "Report Info: " & Format(Now(), "dd mmm yyyy hh:mm"
.Attachments.Add strFileName
.ReadReceiptRequested = False
.Send
End With
Kill strFileName
MsgBox vbCrLf & "Chart has been E-Mailed", _
vbInformation + vbOKOnly, "Chart Exported :"
ExportGraph_Exit:
Set olApp = Nothing
Set olMail = Nothing
Set oleGrf = Nothing
Exit Sub
Public Sub ExportGraph()
On Error GoTo ExportGraph_Err
Dim strErrMsg As String 'For Error Handling
Dim oleGrf As Object
Dim strFileName As String
Dim strFilter As String
Dim lngFlags As Long
Dim olApp As New Outlook.Application
Dim olNameSpace As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Set olNameSpace = olApp.GetNamespace("MAPI"
Set olMail = olApp.CreateItem(olMailItem)
DoCmd.OpenReport "InitialReportForm", acViewPreview
Set oleGrf = Reports("InitialReportForm"
strFileName = ahtCommonFileOpenSave(Flags:=lngFlags, InitialDir:="C:\", _
Filter:="Rich Text Format Files (*.rtf)", FilterIndex:=1, DefaultExt:="rtf", FileName:="MyReport", _
DialogTitle:="Save the Report", OpenFile:=False)
DoCmd.OutputTo acOutputReport, "InitialReportForm", _
acFormatRTF, strFileName, False
MsgBox vbCrLf & "The Report " & strFileName & " has been exported", _
vbInformation + vbOKOnly, "Report exported :"
With olMail
.To = "aroberts@guidemail.com"
.Subject = "Report Info: " & Format(Now(), "dd mmm yyyy hh:mm"
.Attachments.Add strFileName
.ReadReceiptRequested = False
.Send
End With
Kill strFileName
MsgBox vbCrLf & "Chart has been E-Mailed", _
vbInformation + vbOKOnly, "Chart Exported :"
ExportGraph_Exit:
Set olApp = Nothing
Set olMail = Nothing
Set oleGrf = Nothing
Exit Sub