Dear mr/mrs,
Can someone help me with vba, I use below VBA to export data from Access to excel. I have problem with heading rows, not to be delete please help how ( see photos)
Private Sub Command0_Click()
ExportToXLS
End Sub
Public Function ExportToXLS()
Dim objExcel As Excel.Workbook
Set objExcel = Workbooks.Add
Dim objSheet As Excel.Worksheet
Set objSheet = objExcel.Worksheets.Add()
objSheet.Name = "Data"
Dim rec As Recordset
Set rec = CurrentDb.OpenRecordset("SELECT * FROM tblStaf")
objSheet.Range("A4").CopyFromRecordset rec
Dim sPath As String
sPath = CurrentProject.Path
Dim sFilename_full As String
sFilename_full = sPath & "\DataStaf"
On Error Resume Next
objExcel.Close savechanges:=True, FileName:=sFilename_full
Set objExcel = Nothing
End Function
Thank you
Bunga
Can someone help me with vba, I use below VBA to export data from Access to excel. I have problem with heading rows, not to be delete please help how ( see photos)
Private Sub Command0_Click()
ExportToXLS
End Sub
Public Function ExportToXLS()
Dim objExcel As Excel.Workbook
Set objExcel = Workbooks.Add
Dim objSheet As Excel.Worksheet
Set objSheet = objExcel.Worksheets.Add()
objSheet.Name = "Data"
Dim rec As Recordset
Set rec = CurrentDb.OpenRecordset("SELECT * FROM tblStaf")
objSheet.Range("A4").CopyFromRecordset rec
Dim sPath As String
sPath = CurrentProject.Path
Dim sFilename_full As String
sFilename_full = sPath & "\DataStaf"
On Error Resume Next
objExcel.Close savechanges:=True, FileName:=sFilename_full
Set objExcel = Nothing
End Function
Thank you
Bunga