Public Sub ShowFileDialog()
Dim fd As FileDialog
Dim selectedPaths() As String
Dim I As Integer
Set fd = Application.FileDialog(msoFileDialogOpen)
With fd 'Configure dialog box
.AllowMultiSelect = True
.FilterIndex = 2
.Title = "Select Excel File(s)"
.InitialFileName = ""
'Show the dialog and collect file paths selected by the user
If .Show = -1 Then 'User clicked Open
ReDim selectedPaths(.SelectedItems.Count - 1)
'Store file paths for later use.
For I = 0 To .SelectedItems.Count - 1
selectedPaths(I) = .SelectedItems(I + 1)
Next I
End If
.Execute 'Open selected files
End With
Set fd = Nothing
End Sub
|