Link to home
Start Free TrialLog in
Avatar of egunn
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
Avatar of EDDYKT
EDDYKT
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mcrider
mcrider

Here you go!


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!®©
Avatar of egunn

ASKER

Sorry EDDYKT's answer is more elegant.
Avatar of egunn

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
Avatar of egunn

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.