egunn
asked on
Selecting a directory.
Does anybody know of an easy way to select just a directory using the common dialog control? Or perhaps another way that doesn't involve writing a form with a directory selector on it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry EDDYKT's answer is more elegant.
ASKER
Brilliant , I don't suppose you know how to do and FTP directory as well do you. More points in it.
For ftp directory, you can either use wininet.dll or msinet.ocx to build your own directory dialog
ASKER
Thanks, I thought about that but it just seems like a lot of hassel to go to. I've posted another question asking this hopefully somebody's already done it and will let me have the code.
Dim iVal As Long
Dim SelectedPath As String
On Error Resume Next
With CommonDialog1
.filename = "PATH"
.Flags = cdlOFNExplorer
.CancelError = True
.Action = 1
If Err = 0 Then
For iVal = Len(.filename) To 1 Step -1
If Mid$(.filename, iVal, 1) = "\" Then
SelectedPath = Left$(.filename, iVal - 1)
Exit For
End If
Next iVal
End If
End With
MsgBox "You Selected: " + SelectedPath
Cheers!®©