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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find a folder

Status
Not open for further replies.

Zygor

Technical User
Apr 18, 2001
271
0
0
US
Please forgive me but I have searched FAQs and done searches till my eyes are bleeding but I can't seem to find anything to help.

All I want is to be able to have a user click a button and navigate to a folder where they want to save a file to. I tried to use fileopensave but it requires you to select a file. I want to stop at the folder level.

Can anyone shed some light on this?

Thanks
 
You can use browse for folder:

Code:
Option Compare Database

Private Const BIF_RETURNONLYFSDIRS As Long = &H1
Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2
Private Const BIF_RETURNFSANCESTORS As Long = &H8
Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000
Private Const BIF_BROWSEFORPRINTER As Long = &H2000
Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
Private Const MAX_PATH As Long = 260

Function BrowseForFolder(Optional Caption As String, _
    Optional InitialFolder As String) As String

    Dim oFolder As Object
    Dim oApp As Object
    Dim FolderName As Variant
    
    BrowseForFolder = ""
    
    Set oApp = CreateObject("Shell.Application")
 
    'Browse to the folder
    Set oFolder = oApp.BrowseForFolder(0, strCaption, BIF_RETURNONLYFSDIRS, _
        InitialFolder)
        
    If Not oFolder Is Nothing Then
        FolderName = oFolder.Self.Path
        If Right(FolderName, 1) <> "\" Then
            FolderName = FolderName & "\"
        End If

        BrowseForFolder = FolderName
        Set oApp = Nothing
        Set oFolder = Nothing
    End If
End Function

 
The common dialog control can also be a handy tool for this, depending on your UI.

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
Thank you Remou. That's just what I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top