"Sushil" <sk****@dataarmor.net> wrote in message
news:fd**************************@posting.google.c om...
I'm looking for a way to select a directory from a local drive through a
form (like input type="file" except I want to get a directory name not
just a file). I've searched every way I could think of (refer to my brain
comment above) and come up with absolutly nothing.
Any ideas, help or pointers are appreciated.
With Regards,
Sushil Singh
----------------------
Stay not Stop
MsgBox BrowseForFolder("File","Browse for a file","")
MsgBox BrowseForFolder("Folder","Browse for a folder","")
Function BrowseForFolder(sBFF,sPMT,sDIR)
BrowseForFolder = ""
If sBFF <> "Folder" And sBFF <> "File" Then Exit Function
'*
Dim objSHL
Set objSHL = CreateObject("Shell.Application")
Dim objB4F
'*
On Error Resume Next
If sBFF = "Folder" Then
Set objB4F = objSHL.BrowseForFolder(&H0,sPMT,&H0031,sDIR)
Else
Set objB4F = objSHL.BrowseForFolder(&H0,sPMT,&H4031,sDIR)
End If
BrowseForFolder = objB4F.ParentFolder.ParseName(objB4F.Title).Path
If Err.Number <> 0 Then BrowseForFolder = ""
'*
Set objB4F = Nothing
Set objSHL = Nothing
End Function
However, this requires a Microsoft control (MSCOMCTL.ocx, I think) that is
not installed on most PCs; you do get it with a Visual Studio installation,
though.