Transferspreadsheet - insert rows with no header

A

Annette

I have a query that I wish to send to an excel file and insert
beginning at row 3.

The excel file has a "Header" row that is on row 1 and a "Trailer" row
that is on row 4. I need to insert the data from a query into this
excel file at row 3, excluding the header record that comes with
transferspreadsheet.

When I use the following code, I still get a header row (from
transferspreadsheet) and it overwrites data in the "trailer" record
(row 4). In otherwords, it inserts it beginning at row 3 and
overwrites the trailer record that was on row 4. I want it to truely
insert and not overwrite.

DoCmd.TransferSpreadsheet acExport, , "MyQuery", strInputFileName, ,
"A3:W400".

Would I be better off sending this to a temporary table and then
opening excel and have excel import the data rather than pushing it
from access?
 
K

Ken Snell

See the examples on this page:
http://www.accessmvp.com/KDSnell/EXCEL_Export.htm

TransferSpreadsheet ALWAYS inserts the header row of field names. So you'll
need to use one of these methods:
Write Data From a Recordset into an EXCEL Worksheet using Automation (VBA)

Write Data From a Recordset into an EXCEL Worksheet using EXCEL's
CopyFromRecordset (VBA)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top