INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Exporting to Excel Need to Delete top header line

Exporting to Excel Need to Delete top header line

(OP)
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 

RE: Exporting to Excel Need to Delete top header line

You need excel (automation). Either open file and delete first row, or create file and use CopyFromRecordset method to paste data.

combo

RE: Exporting to Excel Need to Delete top header line

(OP)
I'll take a look at this thanks.

RE: Exporting to Excel Need to Delete top header line

Hi,

This code should do it as per combos first suggestion:

CODE --> VBA

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close