View Full Version : Transferspreadsheet to specific cell


jbphoenix
02-12-2009, 08:04 AM
I would like to be able to export data from a query to a specific cell on an excel sheet. I know how to get the data the sheet but can I send it to a specific cell. Here is the code I have to export the data. I would like it to go to cell C10.

DoCmd.TransferSpreadsheet acExport, , "qry_SA_Randy_SDC_2", "\\S\reports\Sales\2009\SA\EMG2009 Randy.xls", False, "KPI"

jal
02-12-2009, 08:47 AM
You can export to a range like this:

DoCmd.TransferSpreadsheet acImport, 8, "Customers", pathToSpreadsheet, True, "MainSheet!C4:E6"

You can export to a named range by assigning the same name to the range as to the query:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryExcelData", pathToXLS, True

If you use an ADODB command object, with an OLEDB connection string to Excel (maybe even an OBDC string might work), you can probably export to a named range like this:


INSERT INTO rangeCustomers (FirstName,LastName) VALUES (......