Hi,

Access lets you export reports by opening the report and going to File/Send/RTF Format (you chose the format, we need rtf, doc, or jpeg). Access then opens up a Microsoft Outlook window with the generic name of the report as it's filename "repName.rtf".
This is a problem for me because we get so many reports daily that we need some organizing by letting the user change the filename of the report being sent by email. So I have this code that lets me export graphs (in forms) to jpeg (or doc, or excel file, whatever I see fit - jpeg in this case). I edited the code to (instead of looking at an ole object in a form) look at a report via:

Dim reportsend as Object
Set reportsend = Reports(repSend)

repSend being the report name. Then I have some code popup outlook with the filename as the attachment. This code works flawlessly for sending graphs of forms... but I get an error when I use an entire report as the exported object.

The error is as follows: Error #: 2465 ... Error Description: Application-defined or object-defined error.

The code I am using (for the saving of the file - emailing not included yet) is as follows:

Private Sub cmdExportGraph_Click()

On Error GoTo cmdExportGraph_Click_Err
Dim strErrMsg As String 'For Error Handling
Dim oleGrf As Object
Dim strFileName As String
Dim strFilter As String
Dim lngFlags As Long

DoCmd.OpenReport "repTest", acViewPreview
Set oleGrf = Reports("repTest")

strFileName = ahtCommonFileOpenSave(Flags:=lngFlags, InitialDir:="C:", _
Filter:="JPEG Files (*.jpg)", FilterIndex:=1, DefaultExt:="jpg", FileName:="MyGraph", _
DialogTitle:="Save the Graph", OpenFile:=False)

oleGrf.Export FileName:=strFileName
MsgBox vbCrLf & "The Chart " & strFileName & " has been exported", _
vbInformation + vbOKOnly, "Chart Exported :"

cmdExportGraph_Click_Exit:
Set oleGrf = Nothing
Exit Sub

cmdExportGraph_Click_Err:
Select Case Err
Case 1004 ' Export Cancelled
Resume cmdExportGraph_Click_Exit
Case Else
strErrMsg = strErrMsg & "Error #: " & Format$(Err.Number) & vbCrLf & vbCrLf
strErrMsg = strErrMsg & "Error Description: " & Err.Description & vbCrLf
MsgBox strErrMsg, vbInformation, "cmdExportGraph_Click"
Resume cmdExportGraph_Click_Exit
End Select

End Sub

Anyone know why this is giving me an error? Thanks.

-Josh