Automatically export to Excel

  • Thread starter Thread starter Mike W
  • Start date Start date
M

Mike W

I have a report which once opened I would like to
automatically export to Excel. I know that this can be
done manually however I would like to have the report
automatically export to Excel. Could someone tell me how
I can program this so that I can save the step of manually
exporting?

Thanks for any and all advice.

Mike
 
See "using the CopyFromRecordset method" discussed in Q247412. You can copy
a DAO or an ADO recordset directly to a range of cells in Excel.
 
Hi Mike,

I don't think there's a simple way of doing this. "Opening" a report
actually does a print preview. What you'd need is an event that fires
when the preview process is complete, and Access doesn't AFAIK expose
one.

It may be possible to do some very clunky stuff with a hidden form and
its timer: set the timer in the report's Open event, let it wait until
the print preview is sure to be ready, and then (in the form's OnTimer
event) run a DoCmd.OutputTo to export the report to Excel. This would
probably work most of the time, but it might be hard to prevent it
running if you did a manual export.

So on the whole I think it would be much simpler just to put a button on
a form somewhere that calls DoCmd.OutputTo to export the report. After
all, its not necessary to preview a report before exporting it.

I have a report which once opened I would like to
automatically export to Excel. I know that this can be
done manually however I would like to have the report
automatically export to Excel. Could someone tell me how
I can program this so that I can save the step of manually
exporting?

Thanks for any and all advice.

Mike

John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
 
That was an extremely useful article.
-----Original Message-----
See "using the CopyFromRecordset method" discussed in Q247412. You can copy
a DAO or an ADO recordset directly to a range of cells in Excel.



.
 
Back
Top