Saturday, April 20, 2019

Excel VBA File Dialog Box – Displaying Vanilla Dialog Box to Pick Files

Excel VBA File Dialog Box – Displaying Vanilla Dialog Box to Pick Files

Solution: You can use Application.FileDialog(msoFileDialogFilePicker) method


Sub ChooseFileUsingFileDialog()

Dim fld As FileDialog
Dim FileChosen As Integer

Set fld = Application.FileDialog(msoFileDialogFilePicker)
FileChosen = fld.Show

If FileChosen <> -1 Then
'Not choosen anything / Clicked on CANCEL
MsgBox "You have choosen nothing"
Else
'display name and complete path of file chosen
MsgBox fld.SelectedItems(1)
EndIf

End Sub

No comments:

Post a Comment