Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sub GetFieldNamesFromXL()
Dim l_appXL As Excel.Application
Dim l_wkbSheetNames As Workbook
Dim l_wksSheet As Worksheet
Dim l_iColumn As Integer
Dim l_rsRecordset As Recordset
Set l_appXL = CreateObject("Excel.Application")
l_appXL.Visible = True
Set l_wkbSheetNames = l_appXL.Workbooks.Open("C:\Temp\Test.xls")
Set l_wksSheet = l_wkbSheetNames.Sheets(1)
Set l_rsRecordset = CurrentDb.OpenRecordset("tblFieldname", dbOpenTable, dbOpenDynamic)
Do Until l_wksSheet.Cells(1, l_iColumn) = ""
l_rsRecordset.AddNew
l_rsRecordset.Fields("FieldName") = l_wksSheet.Cells(1, l_iColumn).Text
l_rsRecordset.Update
l_iColumn = l_iColumn + 1
Loop
'Release xl objects
Set l_rsRecordset = Nothing
Set l_wksSheet = Nothing
l_wkbSheetNames.Close xlDoNotSaveChanges
Set l_wkbSheetNames = Nothing
l_appXL.Quit
Set l_appXL = Nothing
End Sub
ReDim l_sFileName(0)
'Set the Dir to the folder you want to search
l_sFileName(UBound(l_sFileName)) = Dir("C:\Excel\*.xls)
Do Until l_sFileName(UBound(l_sFileName)) = ""
ReDim Preserve l_sFileName(UBound(l_sFileName)+1)
'Using DIR without parameters loops tru' the filelist
l_sFileName(UBound(l_sFileName)) = Dir
Loop