Results 1 to 3 of 3

Thread: [RESOLVED] Get path of folder after getting folder via shell.BrowseForFolder()

  1. #1
    New Member
    Join Date
    Jun 12
    Location
    Wisconsin
    Posts
    9

    Resolved [RESOLVED] Get path of folder after getting folder via shell.BrowseForFolder()

    Hi all,

    I'm trying to get the user to select a folder in which to save files. I need the path, but shell32.shell.BrowseForFolder returns a shell32.Folder object, which doesn't have a .Path method. Here is the code, it's really simple:

    Code:
    'I've added the .Shell32 library
    Private Sub Browse4FolderButton_Click()
    Dim objShell As Shell
    Dim ssfSomething As Variant
    Dim objDestFolder As Folder
    ssfSomething = "P:/Capital Projects"
    Set objShell = New Shell
    Set objDestFolder = objShell.BrowseForFolder(0, "Destination Folder", 0, ssfSomething) 
    'I'm trying to get the user to pick a folder, and then get the path of that folder
    If (Not objDestFolder Is Nothing) Then
        strPath = objDestFolder.Path 
    ' This object (Folder) does not support the .Path method, so how do I get the path of a folder?
    End If
    Set objDestFolder = Nothing
    Set objShell = Nothing
    End Sub
    I feel like the solution to this should be pretty simple, but I have not been able to figure it out and I need to be making progress. I'd be gratefull if someone could point me in the right direction.

  2. #2
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,523

    Re: Get path of folder after getting folder via shell.BrowseForFolder()

    try
    vb Code:
    1. strPath = objDestFolder.self.Path
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    New Member
    Join Date
    Jun 12
    Location
    Wisconsin
    Posts
    9

    Re: Get path of folder after getting folder via shell.BrowseForFolder()

    Brilliant. I never would have gotten that, because the object explorer shows the .self under the Folder2 class, which I thought was different from the Folder class.

    Thanks so much, now I can move on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •