I have the following code that opens a file selector and lets the user pick a file.
Sub SelectFiles(ByRef test As String)
Dim iFileSelect As FileDialog
Sub Main()
Dim test As String
SelectFiles test
Debug.Print test
End Sub
Sub SelectFiles(ByRef test As String)
Dim iFileSelect As FileDialog
Set iFileSelect = Application.FileDialog(msoFileDialogOpen)
With iFileSelect
.AllowMultiSelect = True
.Title = "Select XML Files"
.Filters.Clear
.Filters.Add "Extensible Markup Language Files", "*.xml"
.InitialView = msoFileDialogViewDetails
If .Show = -1 Then
Dim vrtSelectedItem
For Each vrtSelectedItem In iFileSelect.SelectedItems
test = vrtSelectedItem
Next vrtSelectedItem
End If
End With
Set iFileSelect = Nothing
End Sub