View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Browse for folder - Jim Rech's

MD,

You can experiment with the following and see if it does what you want.
It works for me...

'================================================= ============
' Jim Cone - San Francisco, CA - August 12, 2004
' Using code from "Colo"(colo @ consultant.interq.or.jp)
' Provides a list box to select the directory for the file search.
' Second argument will display the text string in the title area of the list box - make it short.
' Third argument specifies the type of display - see Hex values below.
' Fourth argument specifies the start folder. It is optional: "c:\" would bring up the C directory.

' Following constants from Chip Pearson web site:
' BIF_RETURNONLYFSDIRS As Long = &H1,
' BIF_DONTGOBELOWDOMAIN As Long = &H2
' BIF_RETURNFSANCESTORS As Long = &H8,
' BIF_BROWSEFORCOMPUTER As Long = &H1000
' BIF_BROWSEFORPRINTER As Long = &H2000,
' BIF_BROWSEINCLUDEFILES As Long = &H4000

'The following will display the list box with the "C:\Program Files" folder at the top and includes
'the files in the folders (&H4000). Use &H1 to display folders only.
'================================================= ==============
Function GetDirectory(ByRef strMessage As String) As String
On Error GoTo BadDirections
Dim objFF As Object
Set objFF = CreateObject("Shell.Application").BrowseForFolder( 0, strMessage, &H4000, "C:\Program Files")
If Not objFF Is Nothing Then
GetDirectory = objFF.items.Item.Path
Else
GetDirectory = vbNullString
End If
Set objFF = Nothing
Exit Function

BadDirections:
Set objFF = Nothing
GetDirectory = "Err"
End Function
'================================================= ==============

Jim Cone
San Francisco, CA


"MD" wrote in message ...
I'm trying to modify Jim Rech's code for Browse for Folder to give me a
spacific display. In one of his functions (code below), he sets the Desktop
as the root directory (5th line). My modification would be that a specific
directory (c:\MyDirectory\MySpecificDirrectory\). I know that we can set
the code to open in that directory, but you have all the upper folders that
makes the "folder tree" really bothersome to display since my folder is on
a network ... deep deep in my network (about 12 sub-folders deep)!! LOL

If you go in Internet Explorer, click on Favorites/Organize favorites and
click on move, you'll the same box that shows the folder without the higher
folders...

Thank you

Michel

-snip-