Identify invalid folder in VBA

  • Thread starter Thread starter rcl2884
  • Start date Start date
R

rcl2884

I would like users to enter a folder in a worksheet where data will be
stored, but would like to catch invalid folder names in VBA so that I
do not get an error if I pass the invalid folder to the file system
object.

Obviously, I can parse the string myself looking for invalid
characters and counting backslashes etc, but I thought there might be
an easier way to do this. Any ideas?

Thanks, Rick
 
hi,

Sub SelectPath()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
.Show 'afficher la boite de dialogue
Range("A1") = .SelectedItems(1) 'adapt range
End With
End Sub
 
Back
Top