[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Browse for Folder

Posted on 2001-07-27
11
Medium Priority
?
162 Views
Last Modified: 2010-05-02
hi,
i am making a program that needs to browse for folders, and i don't know how to do it, i think many of you can.
please somebody help me.

regards
0
Comment
Question by:samir_tartir
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
11 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 200 total points
ID: 6327436
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6327569
Did you try the standard DirListBox in the toolbox (looks like a yellow folder)?
0
 

Author Comment

by:samir_tartir
ID: 6327600
i almost accepted the answer, but, the program you pointed to me is far to complex (at least for me), what i need to do is this:
press a button (which will display the folder list (which is the same one that is displayed in your program)) and then store the path the user selects.

tell me how, and the points are yours :)

thanks very much
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:rspahitz
ID: 6327722
Add a DirListBox to the form along with this code:

Private Sub Dir1_Change()
  msgbox Dir1.List(Dir1.ListIndex)
End Sub

No button necessary; replace msgbox with wherever you want the path stored.

Note that this only works on the current drive.  If you want to allow the user to change drive, add a DriveListBox also.  Also note that this only supports mapped drives, not network drives.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6327731
Place these controls on a form:
1 listbox
1 commandbutton
1 drivelistbox
1 dirlistbox

Copy this code:
Private Sub Command1_Click()
    List1.AddItem Dir1.Path
End Sub


Now run.
0
 
LVL 2

Expert Comment

by:harnal
ID: 6327753
Do you need to search for a specific folder or list a group of folders so you can select one?  This sounds very simple, I just need a little more info from you about what you are trying to do.
0
 

Author Comment

by:samir_tartir
ID: 6327822
again this is my situation (simplified):
1. i have a form with a button (browse), and a text item (selected path).
2. if i press browse, i need the "browse for folder" to be displayed, so, i can go to the folder i need.
3. when i press ok to the folders window, i need to retrieve the path into the selected path field.
4. note: the browse for folder window can be found when you browse for a certain folder when you are using the windows search.

i hope i was clear this time!
0
 
LVL 2

Expert Comment

by:harnal
ID: 6327845
O.k. go to the project menu, and select components, then select the Microsoft common dialog control, this will provide the functionality you are looking for.
0
 

Author Comment

by:samir_tartir
ID: 6327846
'this is a simplified form of the code emoreau proposed:
Private Sub Command1_Click()
  Dim BI As BROWSEINFO
  Dim pIdl As Long
  Dim sPath As String
  Dim IDL As ITEMIDLIST
  With BI
    .hOwner = Me.hWnd
    If SHGetSpecialFolderLocation(ByVal Me.hWnd, ByVal 0, IDL) = NOERROR Then
      .pidlRoot = IDL.mkid.cb
    End If
    .pszDisplayName = String$(260, 0)
    .lpszTitle = "Browsing is limited to: Default Browse"
    .ulFlags = 1
  End With
  pIdl = SHBrowseForFolder(BI)

  ' If the dialog was cancelled...
  If pIdl = 0 Then Exit Sub
 
  sPath = String$(MAX_PATH, 0)
  SHGetPathFromIDList ByVal pIdl, ByVal sPath
 
  CoTaskMemFree pIdl
 
  MsgBox "This is your path: " + Left(sPath, InStr(sPath, vbNullChar) - 1)
End Sub


of course you need to take the needed subprograms from the attached modules.

emoreau, thanks a lot, it helped.
0
 
LVL 2

Expert Comment

by:harnal
ID: 6327853
Sorry i hit the wrong button, Please Reject this proposed answer so it will reopen the question.
0
 

Author Comment

by:samir_tartir
ID: 6327863
'this is a simplified form of the code emoreau proposed:
Private Sub Command1_Click()
  Dim BI As BROWSEINFO
  Dim pIdl As Long
  Dim sPath As String
  Dim IDL As ITEMIDLIST
  With BI
    .hOwner = Me.hWnd
    If SHGetSpecialFolderLocation(ByVal Me.hWnd, ByVal 0, IDL) = NOERROR Then
      .pidlRoot = IDL.mkid.cb
    End If
    .pszDisplayName = String$(260, 0)
    .lpszTitle = "Browsing is limited to: Default Browse"
    .ulFlags = 1
  End With
  pIdl = SHBrowseForFolder(BI)

  ' If the dialog was cancelled...
  If pIdl = 0 Then Exit Sub
 
  sPath = String$(MAX_PATH, 0)
  SHGetPathFromIDList ByVal pIdl, ByVal sPath
 
  CoTaskMemFree pIdl
 
  MsgBox "This is your path: " + Left(sPath, InStr(sPath, vbNullChar) - 1)
End Sub


of course you need to take the needed subprograms from the attached modules.

emoreau, thanks a lot, it helped.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question