Export Access Table data to Excel - DoCmd.TransferSpreadsheet function

santa12345

Board Regular
Joined
Dec 2, 2020
Messages
66
Office Version
  1. 365
Platform
  1. Windows
Hello.
I have a vb script in Access.
Its been working fine for years.
Basically the script uses a bunch of OpenQuery & TransferSpreadsheet Export commands.

DoCmd.OpenQuery "Sample Query1"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "Sample Query1 Export", "c:\text..xls", True

The XLS template currently has a sample_query1_export tab and the data gets replaced. Everything works great.

Now, I need to add an additional query and export of data to new tab as well.

My issue is, the export works, but it creates an additional tab. Let's say I need the export the data to tab ABC.
Tab ABC exist in the target (text.xls) file - but for some reason, this new export is creating an additional tab ABC_1..not ABC... in the excel template thus causing me errors as I have references in the excel file pointing to tab ABC not ABC_1.

Any ideas would be appreciated.

I'm lost on this one.

Thanks.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,215,071
Messages
6,122,964
Members
449,094
Latest member
Anshu121

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