willspill
12-19-2019, 01:55 AM
Hi,
The code below opens the file dialog and shows all files with a user defined filter. The directory chosen is then used to create a string. However, if no file is chosen and the file picker is cancelled, it returns with an error message. I would like this to not happen and just cancel the script for tidyness' sake. Is this possible?
Thanks
Sub FileOpenDialogBox()
With Application.FileDialog(msoFileDialogFilePicker)
.Filters.Clear
.Filters.Add "Images", "*" & file_type
.AllowMultiSelect = False
.Show
fullpath = .SelectedItems.Item(1)
partialpath = Left(fullpath, Len(fullpath) - 7)
End With
End Sub
The code below opens the file dialog and shows all files with a user defined filter. The directory chosen is then used to create a string. However, if no file is chosen and the file picker is cancelled, it returns with an error message. I would like this to not happen and just cancel the script for tidyness' sake. Is this possible?
Thanks
Sub FileOpenDialogBox()
With Application.FileDialog(msoFileDialogFilePicker)
.Filters.Clear
.Filters.Add "Images", "*" & file_type
.AllowMultiSelect = False
.Show
fullpath = .SelectedItems.Item(1)
partialpath = Left(fullpath, Len(fullpath) - 7)
End With
End Sub