Consulting

Results 1 to 8 of 8

Thread: Solved: Selecting a folder interactively

  1. #1

    Solved: Selecting a folder interactively

    Hi

    I'm working on a program that processes files in a choosen folder. I want the user to select the folder they want to process by browsing in the folder tree. How do I do this?
    For lack of a better idea, I now use a workaround, namely selecting a file by GetOpenFilename, then retrieving the path from the filename.
    [vba]Public MainFolder as String
    Sub SelectFolder()
    MainFolder = Application.GetOpenFilename(, , , , False)
    MainFolder = Left(MainFolder, InStrRev(MainFolder, "\"))
    End Sub[/vba] Anyone knows of a better way?

    Thanks,
    Jimmy
    -------------------------------------------------
    The more details you give, the easier it is to understand your question. Don't save the effort, tell us twice rather than not at all. The amount of info you give strongly influences the quality of answer, and also how fast you get it.

  2. #2
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location

    Browse for folder ...

    It must be your lucky day today.

    Charlize

  3. #3
    Quote Originally Posted by Charlize
    It must be your lucky day today.

    Charlize
    Indeed . Thanks
    -------------------------------------------------
    The more details you give, the easier it is to understand your question. Don't save the effort, tell us twice rather than not at all. The amount of info you give strongly influences the quality of answer, and also how fast you get it.

  4. #4
    VBAX Newbie
    Joined
    May 2007
    Location
    Perth, Western Australia
    Posts
    3
    Location
    I'm looking for something very similar to the request in this post (i.e. allow the user to select a FOLDER into which a file is to be saved, and return the name of the folder to the sub), but also allowing Shortcuts (to folders) and Favourites to be displayed and used to drill down the folder heirachy. (My client has many levels to their folder structure, but I'd prefer NOT to "hard code" one of the lower level folders into the code in order to reduce the amount of drilling-down required.)

    Is this possible? (If not, is it because Shortcuts are treated like files, which I don't want the user to see - only folders?)
    Regards

    BigC
    Let the wind blow through your hair whilst you still have some!

  5. #5
    VBAX Newbie
    Joined
    May 2007
    Posts
    1
    Location

    Great work

    This helped a lot

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by BigC
    I'm looking for something very similar to the request in this post (i.e. allow the user to select a FOLDER into which a file is to be saved, and return the name of the folder to the sub), but also allowing Shortcuts (to folders) and Favourites to be displayed and used to drill down the folder heirachy. (My client has many levels to their folder structure, but I'd prefer NOT to "hard code" one of the lower level folders into the code in order to reduce the amount of drilling-down required.)

    Is this possible? (If not, is it because Shortcuts are treated like files, which I don't want the user to see - only folders?)
    [vba]

    With Application.FileDialog(msoFileDialogFolderPicker)
    .AllowMultiSelect = False
    .Show

    MsgBox .SelectedItems(1)

    End With
    [/vba]

  7. #7
    Bob,

    You never cease to amaze me


    Jimmy
    -------------------------------------------------
    The more details you give, the easier it is to understand your question. Don't save the effort, tell us twice rather than not at all. The amount of info you give strongly influences the quality of answer, and also how fast you get it.

  8. #8
    VBAX Newbie
    Joined
    May 2007
    Location
    Perth, Western Australia
    Posts
    3
    Location
    Wow! I think this gives me almost all of what I want (no Favourites but no matter) and saved over a page of code.

    Many thanks
    Regards

    BigC
    Let the wind blow through your hair whilst you still have some!

Posting Permissions

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