I have a table that I export to Excel but it doesn't export the names of the fields in
my table at the top of the spreadsheet.
This is most likely one option that I left out of my code but have been searching for
how to do this and have not been able to find the answer...
I have included my code below and would appreciate anyone setting me straight on what I left out...
Thanks
my table at the top of the spreadsheet.
This is most likely one option that I left out of my code but have been searching for
how to do this and have not been able to find the answer...
I have included my code below and would appreciate anyone setting me straight on what I left out...
Thanks
Code:
Set objXL = CreateObject("Excel.Application")
Set db = CurrentDb
Set rs1 = db.OpenRecordset("NW_Excel_tbl", dbOpenSnapshot)
If rs1.RecordCount > 0 Then ' if this is an empty table then don't bother...
.Visible = True
Set objWkb = .Workbooks.Open(Out_File)
On Error Resume Next
Set objSht = objWkb.Worksheets("NW") 'RSP
objWkb.Worksheets("RSP").Activate
lngLastRow = objSht.Cells.Find(What:="*", _
After:=objSht.Range("A1"), _
LookAt:=2, _
LookIn:=-4123, _
SearchOrder:=1, _
SearchDirection:=2, _
MatchCase:=False).Row
End With
lngLastRow = lngLastRow + 1
With objSht
.Range("A" & lngLastRow).CopyFromRecordset rs1
With .Rows(lngLastRow & ":" & lngLastRow + rs1.RecordCount)
.Font.Bold = True
.Font.Color = vbBlack
.Font.Name = "Calibri"
.Font.Size = 11
End With
End With
End If
Set rs1 = Nothing
Set objSht = Nothing