A family of Microsoft relational database management systems designed for ease of use.
Try specifying the name of the sheet followed by $ (e.g. Sheet1$) in the Range argument of TransferSpreadsheet.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I need to write a macro for access, that will export the contents of a query to a specific tab on an excel spreadsheet, whilst overwriting the exiting contents. Is this possible?
I have tried various ways, but it always wants to overwrite the excel file altogether!
Thank you.
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Try specifying the name of the sheet followed by $ (e.g. Sheet1$) in the Range argument of TransferSpreadsheet.
You can try my code here:
http://www.btabdevelopment.com/ts/tq2xlspecwspath
But if the data size can be different (rows and/or columns) then you will want to clear the sheet first.
Bob Larson, Former Access MVP (2008-2010) http://www.btabdevelopment.com (free Access tools, tutorials, and samples)
Could you give me an example of full code?
Thanks.
Thanks Bob.
Sorry if this is a stupid question, but where the code states "strTQName" etc, do I litterally replace it with the name of my query, ie "Jack Powell Completions"?
Thanks again.
No, you would copy the entire code (UNCHANGED) into a standard module (not form or report module) and name the module something like basExcelExport (just needs to be different from the procedure name).
Then you would call it in your code or macro using
SendTQ2XLWbSheet "Jack Powell Completions", "NameOfTheWorksheetHere", "PathAndNameOfTheWorkBookHere"
so if the name of the worksheet was MySheet and the path and file was C:\Temp\JackPComp.xlsx" you would use
SendTQ2XLWbSheet "Jack Powell Completions", "MySheet", "C:\TempJackPComp.xlsx"
Bob Larson, Former Access MVP (2008-2010) http://www.btabdevelopment.com (free Access tools, tutorials, and samples)