Excel VBA Learn how to get selected path of the file using file dialog box
The code used in this video:
Sub GettingFile()
Dim SelectedFile As String
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Title = "Select file"
.ButtonName = "Confirm"
.InitialFileName = "C:\"
If .Show = -1 Then
'ok clicked
SelectedFile = .SelectedItems(1)
MsgBox SelectedFile
Else
'cancel clicked
End If
End With
End Sub