BrowseForFolder question

Dennis Wilson

New Member
Joined
Jul 20, 2007
Messages
1
Hello Everyone!

Having a problem with the browseforfolderAPI call, what I'm looking to do is when strStartDir has a value I want the treeview to be expanded to what folder name is in strStartDir. What is currently happening is the folder in strStartDir is being displayed in the treeview as root level. Is there any way to show this folder expanded from the original root of 0&.

Below is the code...

Function PickFolder(strStartDir As Variant) As String

Dim SA As Object, F As Object
Set SA = CreateObject("Shell.Application")

If strStartDir = "" Then
Set F = SA.BrowseForFolder(0, "Choose a folder", 0, 0&)
Else
Set F = SA.BrowseForFolder(0, "Choose a folder", 0, strStartDir)
End If

If (Not F Is Nothing) Then
PickFolder = F.Items.Item.path
frmSettings.lblFilePath = PickFolder
End If
Set F = Nothing
Set SA = Nothing

End Function
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
One way of doing it would be to get the root folder and use
Code:
SendKeys "{DOWN}", True
several times to get to the folder you want. Users path settings would need to be consistent, though.
 

Forum statistics

Threads
1,181,606
Messages
5,930,858
Members
436,764
Latest member
avalladarez

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