Access: Saved Exports

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
I exported data to excel and while doing so it asked me if I wanted to save the steps, which I did. I would like to add a button to a report to run that saved export. Is there a way to do that? There are many users and a button on a form is easier than trying to teach everyone to use the Ribbon.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
The following command runs the saved export:

Code:
DoCmd.RunSavedImportExport "[I][COLOR=#b22222]ExportName[/COLOR][/I]"

This will overwrite the file every time it is run so if you want save it with a dynamic name (i.e. adding the date to the filename) then consider using DoCmd.TransferSpreadsheet
 
Last edited:
Upvote 0
Thank You. What if I wanted to send a query results, in excel, as an attachment in outlook. Is that possible?
 
Upvote 0
There is a few ways, the easiest, would be to create a macro and select the send database object action.


this can be done via vba too:

https://docs.microsoft.com/en-us/office/vba/api/Access.DoCmd.SendObject

It isn't very user friendly because if you want to send it without user input then they get a warning popping up with a short timer before they have to hit send. If the edit argument is true then they can edit and send it ok. another way (avoiding the pop up) is to save the query, then use vba to create a new email and attach the file and send. there is an example here that would just require you to add in the code to save the file (as per previous code) then attach it (oMail.Attachments.Add "FileName") before its sent.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top