开发者

Updating excel tables and pivot tables from within access

开发者 https://www.devze.com 2023-03-04 05:48 出处:网络
I am running an update from within an Access 2010 database using VBA code.The update needs to update some tables by calling queries.This part works fine.I need to call a VBA macro in an Excel workbook

I am running an update from within an Access 2010 database using VBA code. The update needs to update some tables by calling queries. This part works fine. I need to call a VBA macro in an Excel workbook to update the tables and pivo开发者_Go百科t tables (which happen to get their data from the same Access database from which the VBA code is executing).

I get an error on the first line of code in the Excel workbook. The first line simply is to select the approprite worksheet. I know I am over complicating this. But the whole reason is that I have to update the data since the code in the Access macro takes the summary worksheet and spits it out as html in a outlook mail message (which works beautifully).

Should I just take the code for calling the refresh and add the code for the html email to it? Calling the Access stuff first, exit Access, then call the function by calling for Excel to open, do its thing, then exit Excel?


A few options here, since I don't know your exact setup or the whys and wherefors of how things are being done:

  • Try setting your excel pivottables to get their data by linking directly to the access file, instead of copying the data from it. There's an option in pivot table settings to "refresh data on open."

  • Check out the Import External Data wizard in the Data menu of Excel. This will create a worksheet that just links to data. This also has a "refresh data on open" option. Then you can base your pivot tables on this, and have them refresh on open as well. I think the first option is better, however :D

0

精彩评论

暂无评论...
验证码 换一张
取 消