Here's some code that will help (just code snippets), hopefully you get the
idea and it helps.
--
Mark Andrews
RPT Software
http://www.rptsoftware.com
http://www.donationmanagementsoftware.com
-------------------------
'get single file or multiple files (by using ctrl click to select
multiple) and import them in tblImportDiscrepancy
strFiles = GetMultipleExcelFiles(CurrentDBDir, "Ctrl-Click for
Multi-Select")
astrFiles = Split(strFiles, vbNullChar)
If UBound(astrFiles) < LBound(astrFiles) Then
MsgBox "No files were selected"
ElseIf UBound(astrFiles) = LBound(astrFiles) Then
'MsgBox "One file was selected. File (with path) is: " &
astrFiles(LBound(astrFiles))
Call ImportASingleLogFile(astrFiles(LBound(astrFiles)))
Else
J = LBound(astrFiles)
For i = J + 1 To UBound(astrFiles)
Call ImportASingleLogFile(astrFiles(J) & "\" & astrFiles(i))
Next i
End If
-------------------------
Public Function GetMultipleExcelFiles(Optional varDirectory As Variant,
Optional varTitleForDialog As Variant) As Variant
' This function opens a filedialog for selecting one or multiple Excel files
' See TestIT for ways of calling this function
Dim strFilter As String
Dim lngFlags As Long
Dim varFileName As Variant
Dim varFileList() As String
' Specify that the chosen file must already exist,
' don't change directories when you're done
' Also, don't bother displaying
' the read-only box. It'll only confuse people.
lngFlags = ahtOFN_FILEMUSTEXIST Or ahtOFN_HIDEREADONLY Or
ahtOFN_NOCHANGEDIR Or ahtOFN_ALLOWMULTISELECT Or ahtOFN_EXPLORER
If IsMissing(varDirectory) Then
varDirectory = ""
End If
If IsMissing(varTitleForDialog) Then
varTitleForDialog = ""
End If
'Note: if you need a different filter I recommend making another
function
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS*")
varFileName = ahtCommonFileOpenSave(OpenFile:=True, _
InitialDir:=varDirectory, _
Filter:=strFilter, _
Flags:=lngFlags, _
DialogTitle:=varTitleForDialog)
If Not IsNull(varFileName) Then
varFileName = TrimNull(varFileName)
End If
GetMultipleExcelFiles = varFileName
End Function