button to export to Excel?

  • Thread starter Thread starter Jerome
  • Start date Start date
J

Jerome

Hi,

I've got the following situation:

A user needs to export a certain real-time list of data from his Access
2003 database as an Excel file. I've got the query and I know how to
export the query manually. But I need to have a button that the user
simply has to click to get asked where he wants to save (fixed location
is okay too) his XLS file. The app is running in runtime mode.

Is that possible and how do I do that?

Thanks a lot!

Jerome
 
Hi,

To Export a query you can use code like this:

DoCmd.OutputTo acOutputQuery, "QueryName", acFormatXLS, "", True

To Export to a set file fill in the 4th parameter as follows:

DoCmd.OutputTo acOutputQuery, "QueryName", acFormatXLS, "C:\Test.xls",
True

Hope this helps
 
Hi Mark,

Rather than hardcoding the location, how can the user choose where to put it?

Thanks!

Mark said:
Hi,

To Export a query you can use code like this:

DoCmd.OutputTo acOutputQuery, "QueryName", acFormatXLS, "", True

To Export to a set file fill in the 4th parameter as follows:

DoCmd.OutputTo acOutputQuery, "QueryName", acFormatXLS, "C:\Test.xls",
True

Hope this helps
sorry for the double post ...
[quoted text clipped - 13 lines]
 
Yes if you just leave the filename blank then a save as dialog will show.

CJG via AccessMonster.com said:
Hi Mark,

Rather than hardcoding the location, how can the user choose where to put it?

Thanks!

Mark said:
Hi,

To Export a query you can use code like this:

DoCmd.OutputTo acOutputQuery, "QueryName", acFormatXLS, "", True

To Export to a set file fill in the 4th parameter as follows:

DoCmd.OutputTo acOutputQuery, "QueryName", acFormatXLS, "C:\Test.xls",
True

Hope this helps
sorry for the double post ...
[quoted text clipped - 13 lines]
 
Back
Top