TransferSpreadsheet Headers (1 Viewer)

crownedzero

Registered User.
Local time
Today, 00:43
Joined
Jun 16, 2009
Messages
54
Code:
Private Sub Cust_Report_Click()
    
    Dim Identity As Variant
    Dim Location As String
    Dim Extension As String
    Dim Identity1 As String
    Dim stDocName As String
        
    On Error Resume Next
        
        Extension = ".xls"
        Identity = Format(Date, "mmddyy")
        Identity1 = Identity & Extension
        Location = "N:\filepath\file" & Identity1
        stDocName = "qry"
        
    DoCmd.SetWarnings False
    DoCmd.RunSQL "DELETE * FROM tbl"
    DoCmd.OpenQuery stDocName, acNormal, acEdit
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "tbl", Location, False, ""
    DoCmd.SetWarnings True

    
End Sub

I'm still getting headers . . . Am I forgetting something?
 

SOS

Registered Lunatic
Local time
Yesterday, 22:43
Joined
Aug 27, 2008
Messages
3,517
First, you don't need to include the

, " "

at the end. Just use:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "tbl", Location, False

and if that doesn't do it for you, perhaps this code will (just modify the part to remove the iteration through putting the headers in place.
 

crownedzero

Registered User.
Local time
Today, 00:43
Joined
Jun 16, 2009
Messages
54
Even by dropping the Header syntax (default is false I think) I can't seem to remove them I'll give the link a shot.
 

SOS

Registered Lunatic
Local time
Yesterday, 22:43
Joined
Aug 27, 2008
Messages
3,517
Even by dropping the Header syntax (default is false I think) I can't seem to remove them I'll give the link a shot.

Just to make it easier on you - in the code from that link, disable this part:

Code:
[FONT=Courier New]    For Each fld In rst.Fields
        ApXL.ActiveCell = fld.Name
        ApXL.ActiveCell.Offset(0, 1).Select
    Next
[/FONT]

if you don't want the headers.
 

Users who are viewing this thread

Top Bottom