Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locate a folder and save as string 3

Status
Not open for further replies.

BradCollins

Technical User
Sep 2, 2003
116
0
0
AU
I have developed a form for database settings, on this form I have a text field that contains a drive path,I want to be able to have users of my app click a button that will launch somehting like the fileopen dialog, they can then browse their drives and directories to select a folder (not a file) and then return this selection as a string.
Is this possible and how ??? any help will be most appreciated.
 
In a standard code module create a function like this:
Code:
Function PickFolder(strStartDir) As String
    Dim SA As Object, F As Object
    Set SA = CreateObject("Shell.Application")
    Set F = SA.BrowseForFolder(0, "Choose a folder", 0, strStartDir)
    If (Not F Is Nothing) Then
        PickFolder = F.Items.Item.Path
    End If
    Set F = Nothing
    Set SA = Nothing
End Function
Then, in the Click event procedure of your button, you can code something like this:
Me![name of textbox] = PickFolder("\path\to\root directory")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

thats perfect, worked first go, thanks for that

Brad

[thumbsup][thumbsup][thumbsup][thumbsup][thumbsup]
 
Although this works fine, is there a way tht when it brings up the folder selection box, that you can see all drives available and not just the c:\ drive ?
 
The sample codes works, but doesn't seem to recoginize the 'start' folder.

For example, I want the initial folder to be set at a specific folder, and most likely it won't be any of the Windows Special folders.

Can this be done?

If it was easy, everybody would do it.
 
Works for me, provided strStartDir is a Variant.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top