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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting to Excel Need to Delete top header line

Status
Not open for further replies.

LimitedTech

Technical User
Aug 4, 2008
71
US
I use the following code to export to an excel spread sheet to upload. I need the first line to be deleted on the excel sheet. It has the field names on it and the place I upload needs only the data. I have searched but am unable to find a solution.
OR
the alternate is to prevent it from being included to start with.

Code:
Private Sub Command13_Click()
Dim strQryName As String, strXLFile As String, strName As String
DoCmd.OpenQuery "QryCheckAppend"
DoCmd.OpenQuery "QryChecksAppendBills"
strQryName = "QryDailyChecks"
strXLFile = "Z:\MyDocuments\RptChecksWritten.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, strQryName, strXLFile
FollowHyperlink "Z:\MyDocuments\RptChecksWritten.xls"
End Sub
 
You need excel (automation). Either open file and delete first row, or create file and use CopyFromRecordset method to paste data.

combo
 
Hi,

This code should do it as per combos first suggestion:

Code:
DoCmd.TransferSpreadsheet TransferType:=acExport, SpreadsheetType:=acSpreadsheetTypeExcel9, TableName:="Query1", FileName:="C:\test\template.xls", Range:="exportRange"

    Dim XL As Object
        Set XL = CreateObject("Excel.Application")
        With XL
        .Visible = False
          .displayalerts = False
          .Workbooks.Open "C:\test\template.xls"
          .Rows("1:1").Delete
          .ActiveWorkbook.Close (True)
          .Quit
        End With
        Set XL = Nothing

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top