Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export to a specific worksheet using transferspreadsheet

Status
Not open for further replies.

neeko1226

MIS
Jul 24, 2003
82
US
Is it possible to export to a specific worksheet in Excel and overwrite the existing data using the transferspreadsheet method in VBA? I need to export a query to a worksheet that holds the raw data in an Excel workbook. There are several other worksheets in the workbook that connected to the "data" worksheet. Right now this code is creating a new worksheet (data1) in the workbook.

Code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qry_CDL_Sum_Test", "L:\Riskman\Mock Exam\CDL Summary\CD_Loan_Summary.xls", True, "Data"

Any help would be greatly appreciated.
 
You may try this:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qry_CDL_Sum_Test", "L:\Riskman\Mock Exam\CDL Summary\CD_Loan_Summary.xls", True, "Data$"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you for the reply PHV, but I guess it's not all about the $ here. I added the the $ and received the following error message:

"Run-time error '3010'
Table 'Data$' already exists."

I've been searching the net for a solution and it looks like some people are activating the worksheet, clearing it out and then repopulating it with VBA code. The examples our on the web are very complex and beyond my capabilities. Does anyone have a simple version that I could build off of? I know how to create a recordset and loop through it, but I don't know how to assign values from the recordset to another source.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top