I am trying to save a report as a PDF File instead of a
RTF File and am having some difficulties with the code.
Below is my code for saving and Emailing the Report as an
RTF. I have not been able to change the RTF settings to PDF and have any luck. Just wandering if anyone has a solution. Thanks
Public Sub Savegraph_Click()
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 "RPTSNFREPORT", acViewPreview
Set oleGrf = Reports("RPTSNFREPORT"
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, "RPTSNFREPORT", _
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
.Display
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
ExportGraph_Err:
Select Case Err
Case 1004 ' Export Cancelled
Resume ExportGraph_Exit
Case Else
strErrMsg = strErrMsg & "Error #: " &
Format$(Err.Number) & vbCrLf & vbCrLf
strErrMsg = strErrMsg & "Error Description: "
& Err.Description & vbCrLf
MsgBox strErrMsg, vbInformation, "ExportGraph"
Resume ExportGraph_Exit
End Select
End Sub
.
RTF File and am having some difficulties with the code.
Below is my code for saving and Emailing the Report as an
RTF. I have not been able to change the RTF settings to PDF and have any luck. Just wandering if anyone has a solution. Thanks
Public Sub Savegraph_Click()
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 "RPTSNFREPORT", acViewPreview
Set oleGrf = Reports("RPTSNFREPORT"
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, "RPTSNFREPORT", _
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
.Display
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
ExportGraph_Err:
Select Case Err
Case 1004 ' Export Cancelled
Resume ExportGraph_Exit
Case Else
strErrMsg = strErrMsg & "Error #: " &
Format$(Err.Number) & vbCrLf & vbCrLf
strErrMsg = strErrMsg & "Error Description: "
& Err.Description & vbCrLf
MsgBox strErrMsg, vbInformation, "ExportGraph"
Resume ExportGraph_Exit
End Select
End Sub
.