R
Richard
I have a module which imports text files into a database, but I need
to be able to select multiple files to be processed, this is what I
have so far
Public filename As String
Sub SelectFile()
Dim fd As FileDialog
Dim objfl As Variant
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.ButtonName = "Select"
.AllowMultiSelect = True
.Filters.Add "Text Files", "*.txt;*.txt", 1
.Title = "Choose your files"
.Show
For Each objfl In .SelectedItems
filename = objfl
Next objfl
If .SelectedItems.Count > 0 Then
For i = 1 To .SelectedItems.Count
Call OpenText 'this is what imports the text
Next i
End If
End With
End Sub
I think I need to combine the For and If statements to make it work,
it will import the first file selected and if I choose two files it
will repeat the import of the first file selected. Any help is greatly
appreciated
Richard
to be able to select multiple files to be processed, this is what I
have so far
Public filename As String
Sub SelectFile()
Dim fd As FileDialog
Dim objfl As Variant
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.ButtonName = "Select"
.AllowMultiSelect = True
.Filters.Add "Text Files", "*.txt;*.txt", 1
.Title = "Choose your files"
.Show
For Each objfl In .SelectedItems
filename = objfl
Next objfl
If .SelectedItems.Count > 0 Then
For i = 1 To .SelectedItems.Count
Call OpenText 'this is what imports the text
Next i
End If
End With
End Sub
I think I need to combine the For and If statements to make it work,
it will import the first file selected and if I choose two files it
will repeat the import of the first file selected. Any help is greatly
appreciated
Richard