CodeItBetter Programming Another VB Programming Blog

How to show Browse for folder

Posted on July 27, 2011
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'File/Folder Handling - How to show Browse for folder
Private Const BIF_RETURNONLYFSDIRS As Long = &H1
Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2
Private Const BIF_RETURNFSANCESTORS As Long = &H8
Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000
Private Const BIF_BROWSEFORPRINTER As Long = &H2000
Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
Private Const MAX_PATH As Long = 260
 
Function BrowseFolder(Optional Caption As String, Optional InitialFolder As String) As String
    'Set a reference to "Microsoft shell controls and automation"
    Dim SH As Shell32.Shell
    Dim F As Shell32.Folder
    Set SH = New Shell32.Shell
    Set F = SH.BrowseForFolder(0&, Caption, BIF_RETURNONLYFSDIRS, InitialFolder)
    If Not F Is Nothing Then
        BrowseFolder = F.Items.item.Path
    End If
End Function
 
Private Sub Command1_Click()
    'How to call this function
    Dim FName As String
    FName = BrowseFolder("Select a folder to Insert Pictures", "My Computer")
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.