Share via

Export Microsoft Access Reports to Excel

Anonymous
2022-10-04T13:35:20+00:00

Hi all,

I am using the below routine to export Access Queries successfully now I need to export some Access Reports but same routine throwing bellow error. Anyone can help me to modify or write a new Query to export reports from Access.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "Rpt\_SPECD\_BendAngles", conPath & "Metal\_SPX\_PCMCd.xls", True 

Thanks for your support.

Microsoft 365 and Office | Access | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. HansV 462.6K Reputation points
    2022-10-04T18:00:02+00:00

    You have to change the OutputFile argument as well as the ObjectName argument:

    DoCmd.OutputTo ObjectType:=acOutputReport, ObjectName:="Rpt_SPECD_BendAngles", OutputFormat:=acFormatXLS, OutputFile:=conPath & "Metal_SPX_sPECD.xls"

    DoCmd.OutputTo ObjectType:=acOutputReport, ObjectName:="Rpt_SPECD_BoltSelectionFilter", OutputFormat:=acFormatXLS, OutputFile:=conPath & "SomeOtherName.xls"

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2022-10-04T15:47:02+00:00

    Dear HansV Thanks for the quick reply,

    I can export Report with above mention routine but when I export more than one report in one go (Example find below) last report will survive and rest of reports generate early replaced. Is this possible routine can add worksheets, not generate workbook every time.

    DoCmd.OutputTo ObjectType:=acOutputReport, ObjectName:="Rpt\_SPECD\_BendAngles", OutputFormat:=acFormatXLS, OutputFile:=conPath & "Metal\_SPX\_sPECD.xls" 
    
    DoCmd.OutputTo ObjectType:=acOutputReport, ObjectName:="Rpt\_SPECD\_BoltSelectionFilter", OutputFormat:=acFormatXLS, OutputFile:=conPath & "Metal\_SPX\_sPECD.xls" 
    

    Thanks in advance.

    Was this answer helpful?

    0 comments No comments
  3. HansV 462.6K Reputation points
    2022-10-04T13:47:01+00:00

    DoCmd.TransferSpreadsheet can only export tables and select queries. It cannot handle reports.

    You can use DoCmd.OutputTo for this purpose:

    DoCmd.OutputTo ObjectType:=acOutputReport, ObjectName:="Rpt_SPECD_BendAngles", OutputFormar:=acFormatXLS, OutputFile:=conPath & "Metal_SPX_PCMCd.xls"

    But please keep in mind that this is only a bare-bones export of the data in the report, all formatting will be lost.

    Was this answer helpful?

    0 comments No comments