Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!
Private Sub Command2_Click() Const cstrFolder As String = "C:\Schedules\" Dim i As Long, x As Long, lng As Long Dim xlApp As Object Dim xlWrk As Object Dim xlSheet As Object Dim sql As String Dim strExt As String, strFile As String, strTable As String Set xlApp = VBA.CreateObject("Excel.Application") xlApp.Visible = False ' strExt = ".xls" lng = Len(strExt) strFile = Dir(cstrFolder & "*" & strExt) If Len(strFile) = 0 Then MsgBox "No Files Found" Else Do While Len(strFile) > 0 'MsgBox (cstrFolder & " - " & strFile) 'ADD EXCEL CODE HERE Set xlWrk = xlApp.Workbooks.Open(cstrFolder & strFile) '("C:\ExcelImportFile.xls") Set xlSheet = xlWrk.Sheets("Sheet1") For i = 11 To 41 sql = "Insert Into [tblTechAvailability] (Day,Availability,Notes) VALUES ('" & xlSheet.Cells(i, 1).Value & "','" & xlSheet.Cells(i, 2).Value & "','" & xlSheet.Cells(i, 3).Value & "')" DoCmd.RunSQL sql Next i xlWrk.Close 'xlApp.Quit Set xlSheet = Nothing Set xlWrk = Nothing 'Set xlApp = Nothing 'END EXCEL CODE HERE x = x + 1 'KEEPS COUNT OF IMPORTED FILES strFile = Dir() Loop xlApp.Quit Set xlApp = Nothing MsgBox x & " File(s) were imported" End If End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.