Common directory tree view in an userform

bruno.trudo

Board Regular
Joined
Jan 14, 2004
Messages
98
Hi guys,
is there a way how can I show and use a common directory tree view or list (I mean a one with yellow folders next to the directory) in my userform?
Thanks
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

jimboy

Well-known Member
Joined
Apr 11, 2002
Messages
2,314
Hi - welcome to the board.

This will bring up the Browse for folder box and load textbox1 with the selected drive & folder, you will need CommandButton1 and textbox1 on your userform...

Code:
Private Sub CommandButton1_Click()
Dim objShell As Object
Dim objFolder As Object
Dim strFolderFullPath As String

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Please select a folder", 0, "C:\MyFolders\TestFolder")

If (Not objFolder Is Nothing) Then
    
    On Error Resume Next
    If IsError(objFolder.Items.Item.Path) Then strFolderFullPath = CStr(objFolder): GoTo Here
    On Error GoTo 0
    
    If Len(objFolder.Items.Item.Path) > 3 Then
        strFolderFullPath = objFolder.Items.Item.Path & Application.PathSeparator
    Else
        strFolderFullPath = objFolder.Items.Item.Path
    End If
Else
    MsgBox "User cancelled": End
End If

Here:
'Loads Textbox1 with drive
TextBox1.Value = strFolderFullPath
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,129,683
Messages
5,637,787
Members
416,982
Latest member
lisam77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top