I'm developing an Access 2007 "project" (.ADP) as a front-end to a SQL Server 2005 Express database.
I would like to give the user the option of saving a report as an Excel spreadsheet, but the attached code always generates the error message :
Error Numb : 2587 " .. can't complete the Ouput operation"
If I use "acFormatRTF" instead of "acFormatXLS" it works OK and creates a text file.
Also, "acFormatXLS" works OK if I try to export the contents of a Table using "acOutputTable".
Can anyone tell me why the "acOutputReport / acFormatXLS" combination does not work?
I have also tried to use "acOutputQuery" and supplied the name of a SQL Server "view", but that creates a similar error message.
DoCmd.OpenReport strReportName, acViewPreview, , , , strLongOpenArgs
DoCmd.OutputTo acOutputReport, strReportName, acFormatXLS, Me.txtReportFileName
DoCmd.Close acReport, strReportName