I use the following code to select a file and return its name
It works fine, but when NO file is selected returns an error.
Is there a way to amend the code so that the code will return a message saying something like No file is selected.
Function FileOpenDialogBox()
'Display a Dialog Box that allows to select a single file.
'The path for the file picked will be stored in fullpath variable
With Application.FileDialog(msoFileDialogFilePicker)
'Makes sure the user can select only one file
.AllowMultiSelect = False
'Filter to just the following types of files to narrow down selection options
.Filters.Add "Excel Files", "*.xlsx; *.xlsm; *.xls; *.xlsb", 1
'Show the dialog box
.Show
'Store in fullpath variable
fullpath = .SelectedItems.Item(1)
FileOpenDialogBox = fullpath
End With
End Function
Bookmarks