View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default Browsing for a folder name?

Hi Don,

Don Wiss wrote:
Thanks Robin. It works fine. A nice enhancement though would be to
control the root folder it opens with. Changing that line and giving
it a string gets a type mismatch. Anyone know how to change it from
Desktop to a specified folder as the root?


You can go to Stephen Bullen's page

http://bmsltd.ie/MVP/Default.htm

and look for BrowseForFolder.zip under Jim Rech. That one allows you to
specify an initial directory.

Alternatively, you can automate the Shell interface to do this:

Sub test()
Dim sh As Object
Dim fol As Object
Dim fi As Object

Set sh = CreateObject("Shell.Application")

Set fol = sh.BrowseForFolder(0, _
"Select Folder", 0, "C:\")

If Not fol Is Nothing Then
Set fi = fol.ParentFolder.ParseName(fol.Title)
If Not fi Is Nothing Then
MsgBox fi.Path
Else
MsgBox fol.Title
End If
Set fol = Nothing
Else
MsgBox "no folder selected"
End If
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]