Code to Exclude Column Headings from Transferring to Excel 2007 from Access 2007

≡放荡痞女 提交于 2019-12-02 02:10:15

From Access:

Sub XLTrans()
''Reference: Microsoft ActiveX Data Object x.x Library
Dim rs As New ADODB.Recordset
Dim xl As Object ''Excel.Application
Dim wb As Object ''Workbook

Set xl = CreateObject("Excel.Application")

Set wb = xl.Workbooks.Add

''Connection relevant for 2007 or 2010
rs.Open "MyTableOrQuery", CurrentProject.AccessConnection

wb.Sheets(1).Cells(1, 1).CopyFromRecordset rs

xl.Visible = True

End Sub

If you insist on using the transferspreadsheet;

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "tbl_one", xlfile, True

Dim xl As Object
Dim wb As Object

Set xl = CreateObject("Excel.Application")
Set wb = xl.Workbooks.Open(xlfile)

xl.DisplayAlerts = False
With wb.Worksheets(1)
    .Rows(1).Delete
End With
wb.Save
xl.Visible = True
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!