Folder Open

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • questionit
    Contributor
    • Feb 2007
    • 553

    Folder Open

    I have this code to open Folder view. I am not sure how to retreive name and path of the selected folder and assign it to a variable (string type) ..Help please


    [code=vb]
    Public shlShell As Shell32.Shell
    Public shlFolder As Shell32.Folder
    Const BIF_RETURNONLYF SDIRS = &H1

    Public Sub Command2_Click( )

    Set shlShell = New Shell32.Shell
    Set shlFolder = shlShell.Browse ForFolder(Me.Hw nd, "Select a Folder", BIF_RETURNONLYF SDIRS)
    End Sub
    [/code]
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Hi
    Originally posted by questionit
    I have this code to open Folder view. I am not sure how to retreive name and path of the selected folder and assign it to a variable (string type) ..Help please


    [code=vb]
    Public shlShell As Shell32.Shell
    Public shlFolder As Shell32.Folder
    Const BIF_RETURNONLYF SDIRS = &H1

    Public Sub Command2_Click( )

    Set shlShell = New Shell32.Shell
    Set shlFolder = shlShell.Browse ForFolder(Me.Hw nd, "Select a Folder", BIF_RETURNONLYF SDIRS)
    End Sub
    [/code]
    Do you need to use the shell ?

    Perhaps you could use the FileDialogue

    Code:
    Dim fd As FileDialog
        Set fd = Application.FileDialog(msoFileDialogFolderPicker)
        With fd
            .Show
            If .SelectedItems.Count <> 0 Then MsgBox .SelectedItems(1)
        End With
    ??

    You will need a reference to Microsoft Office Object Library

    Just a thought

    MTB

    Comment

    Working...