Hi All,
I am working on macro where in, i need to browse for a folder by clicking on browse button.
here is the code that i am using for it
Sub Browse()
Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
.Title = "Select a Folder"
.AllowMultiSelect = False
.Show
sItem = .SelectedItems(1)
End With
Set fldr = Nothing
End Sub
Now when the file dialog opens to select a folder, if i click on Cancel button, the code crashes at "sItem = .SelectedItems(1)" how to fix this issue?
Please help.
Thank you.
Bookmarks