VBA select file path or select file to open.

VBA that saves the filepath that the user selects.

Dim diaFolder As FileDialog
 Dim ipath As String
 MsgBox "Select folder path"
 Set diaFolder = Application.FileDialog(msoFileDialogFolderPicker)
 diaFolder.AllowMultiSelect = False
 diaFolder.Show
ipath = diaFolder.SelectedItems(1)
msgbox "You selected filepath: " & ipath

 

VBA that asks user which file to open.

MsgBox "Select which file to Open"
ipath = Application.GetOpenFilename(filefilter:="", Title:="Open")
Application.Workbooks.Open (ipath)

 

Interested in learning new skills?