RichardMGreen
Well-known Member
- Joined
- Feb 20, 2006
- Messages
- 2,177
Hi all
I've got the following code:-
which allows users to select a folder which is used further on in the code. If you select Cancel when the folder picker appears, I get a null string returned and it causes problems further on.
How would I modify it so that if a user selects Cancel it keeps the current folder?
I've tried checking if the selected.items.count is more than 0 (placed around the for/next statement) but that's not helped.
Any help greatly appreciated.
I've got the following code:-
Code:
Function GetFolderName(Optional OpenAt As String) As String
Dim lCount As Long
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = OpenAt
.Show
For lCount = 1 To .SelectedItems.Count
GetFolderName = .SelectedItems(lCount)
Next lCount
End With
End Function
which allows users to select a folder which is used further on in the code. If you select Cancel when the folder picker appears, I get a null string returned and it causes problems further on.
How would I modify it so that if a user selects Cancel it keeps the current folder?
I've tried checking if the selected.items.count is more than 0 (placed around the for/next statement) but that's not helped.
Any help greatly appreciated.