Exporting Access Query data into existing Excel Workbook?

sagain2k

Board Regular
Joined
Sep 8, 2002
Messages
94
I have a macro that currently exports a query into a new Excel workbook with a given path and name. How can you tell it to export (insert) into an exisitng Excel workbook instead? Here's the current code that from within Access creates an Excel file with the Query data in it:

DoCmd.OutputTo acQuery, "qryCourseScheduleRpt", "MicrosoftExcel(*.xls)", _
"q:\qryResults\EngCourseSched.xls", True, ""

What I want is to be able to have a template Excel workbook that any query can be exported into (and that template Excel workbook will have macros associated with it that can then format the imported query data.

Thanks for any suggestions!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Change from using OutputTo to TransferSpreadsheet.

eg

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "Exclusions", "C:\PPI\Exclusions.xls!Sheet1"

This exports the query/table Exclusions to an already existing Excel workbook called Exclusions.xls which is in C:\PPI.

BTW the query is imported into a new worksheet called Exclusions, something which you will need to consider for the Excel formatting.
 
Upvote 0

Forum statistics

Threads
1,215,561
Messages
6,125,542
Members
449,236
Latest member
Afua

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