Function Impo_allExcel()
Dim StartTime As Double
Dim SecondsElapsed As Double
Dim myfile As String
Dim mypath As Object
Dim mypath2 As String
Dim mymacro As Object
Dim mymacro2 As String
Dim mytable As String
Dim xl As Object
StartTime = Timer
mytable = InputBox("Please enter target table")
MsgBox ("Please Select Formatting Macro")
Set mymacro = Application.FileDialog(3)
mymacro.Show
mymacro2 = mymacro.SelectedItems(1)
MsgBox ("Please Select Source Data Folder")
Set mypath = Application.FileDialog(4)
mypath.Show
mypath2 = mypath.SelectedItems(1) & "\"
MsgBox ("Please Select Folder of Data to be Formated")
Set xl = CreateObject("Excel.Application")
xl.Workbooks.Open (mymacro2)
xl.Visible = False
xl.Run "Format_All_Workbooks"
xl.ActiveWorkbook.Close (True)
xl.Quit
Set xl = Nothing
ChDir (mypath2)
myfile = Dir(mypath2)
Do While myfile <> ""
If myfile Like "*.xls" Then
DoCmd.TransferSpreadsheet acImport, 8, mytable, mypath2 & myfile, True
End If
myfile = Dir()
Loop
MinutesElapsed = Format((Timer - StartTime) / 86400, "hh:mm:ss")
MsgBox "This code ran successfully in " & MinutesElapsed & " minutes", vbInformation
End Function