Automate Access Macro to run Access Query and Export to Excel

weasyb

New Member
Joined
Aug 4, 2015
Messages
11
Dear MVP's:

I would really appreciate help with this...

I have an access database that contains a macro which runs a query. I would like to know how to automate this macro so that it runs this query and copies query results from access to excel, refreshes the pivot tables and saves a copy of the report to a folder. The source file is also copied over. I do not know VBA. Is there a simple way to do this?


Any thoughts or suggestions would be greatly appreciated.


Thank you,

Lisa
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Can't you just import the query into Excel?
 
Upvote 0
There is a macro that runs several queries in my access database.

The macro is a macro and not a procedure in a module.

This macro (not a module) runs several queries.

Once query is run, the user is supposed to take the previous weeks excel report and do a "save as" and rename it to the current week and copy each query output to its corresponding data tab in excel.

Then refresh all pivot tables in this excel workbook and save the spreadsheet to a particular folder path.



Any suggestions to point me in the right direction would be greatly appreciated.



Thank you,



Lisa
 
Upvote 0
Take a look at the TransferSpreadsheet function to see if you could work with it.
https://msdn.microsoft.com/en-us/library/office/ff844793.aspx
Opening the workbook afterwards would automatically refresh the pivot tables as long as the underlying data structure for the pt is the same. If you are willing to do a bit of work, there are lots of 'net sources with examples on how to copy files. Or you could simply open the workbook and continue to do your Save As. Sorry, I don't have any ready to use code for file copying (have only done this with batch files or created new files using VBA).
 
Upvote 0
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule #10 here: Forum Rules).

This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

For a more complete explanation on cross-posting, see here: Excelguru Help Site - A message to forum cross posters).

Thanks
 
Upvote 0

Forum statistics

Threads
1,215,086
Messages
6,123,040
Members
449,092
Latest member
ikke

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