Hi Sean,
VBA help tells me to leave the second argument blank, but an error is raised
It says to leave the second argument blank if you want to export the active
object. Trouble is, your report is likely not active at the time you are
running this code. Try the following procedure instead:
Sub ExportReportAsRTF()
On Error GoTo ProcError
DoCmd.OutputTo ObjectType:=acOutputReport, ObjectName:="rptArtists", _
OutputFormat:=acFormatRTF, AutoStart:=False
ExitProc:
Exit Sub
ProcError:
Select Case Err.Number
Case 2501 ' User clicked on cancel
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure ExportReportAsRTF..."
End Select
Resume ExitProc
End Sub
or
Sub ExportReportAsRTF2()
On Error GoTo ProcError
DoCmd.OutputTo ObjectType:=acOutputReport, ObjectName:="rptArtists", _
OutputFormat:=acFormatRTF, OutputFile:="Test.rtf", _
AutoStart:=False
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure ExportReportAsRTF..."
Resume ExitProc
End Sub
These subroutines can easily be modified to pass in the name of the report
as a parameter, instead of hard coding. Your choice. Be aware that exporting
reports in RTF format can leave a lot to be desired. This is not a WYSIWYG
export. For example, lines and checkboxes are not exported correctly.
Tom
________________________________________
:
Hi there,
I am trying to write some code to export a report to file (preferred RTF).
Ho do I save the current report? VBA help tells me to leave the second
argument blanc, but an error is raised
DoCmd.OutputTo acOutputReport, , acFormatRTF, file_loc, True
Any help appreciated
Thx, Sean