+ Reply to Thread
Results 1 to 15 of 15

Opening a Dialog Box for Folder Selection

  1. #1
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    Opening a Dialog Box for Folder Selection

    Hi all,

    I have a file path i wish to save to within my VBA code however part of the file path needs to be selected depending what what you are working on

    For Example my file path would be:

    C:\Users\simon.ward\Desktop\Stores\2013\Sept\Mansfield\Reports

    The Year and Month i can pre-set as variables so no problem there but the Region (ie Mansfield) is a variable which i need to select because within the "Sept" folder there will be many region names which i need to choose from, each of which having a "Reports" folder within.

    I was hoping that Excel could be good enough to pop up a Dialog box which lists the Region folders for the user select which will set the variable within the code

    Hope that all makes sense

    Many Thanks in advance

    Simon
    Last edited by Simon.Ward; 01-21-2014 at 06:32 AM.

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Opening a Dialog Box for Folder Selection

    You may use:
    Please Login or Register  to view this content.
    Simply pass the initial file path to the function.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  3. #3
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Opening a Dialog Box for Folder Selection

    Thanks for that, but sorry how do you "pass to the function" ?

    Thanks

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Opening a Dialog Box for Folder Selection

    NOT MY CODE, but a quick google finds this, which seems to do exactly what you want:

    http://www.your-save-time-and-improv...ct-folder.html
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  5. #5
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Opening a Dialog Box for Folder Selection

    Great yeh that bring the diolog box up which is perfect but do you know if you can set a default pathway to save having to start at the drive

    So in my case instead of having to start by select c:\ etc etc i'd like the dialog box to start at C:\Users\simon.ward\Desktop\Stores\2013\Sept\

    Thanks

  6. #6
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Opening a Dialog Box for Folder Selection

    You may use:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Opening a Dialog Box for Folder Selection

    Sorry to sound dumb but where would i put this?

  8. #8
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Opening a Dialog Box for Folder Selection

    Wherever in your code you wish to retrieve the folder path.

  9. #9
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Opening a Dialog Box for Folder Selection

    Sorry Im lost

  10. #10
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Opening a Dialog Box for Folder Selection

    I do not know what your code is, so I cannot tell you where to put this. If you will post your code, I will show it.

  11. #11
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Opening a Dialog Box for Folder Selection

    Sorry being dense, just worked it out

  12. #12
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Opening a Dialog Box for Folder Selection

    Thanks very much seems that sorted it out

  13. #13
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Opening a Dialog Box for Folder Selection

    Sorry one more thing, how do you create a msgbox if some clicks cancel to a dialog box (NOT an inputbox) is it possible?

  14. #14
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Opening a Dialog Box for Folder Selection

    Dialog returns -1 if Ok is pressed. If you wish to show message if user does not choose a folder, you may test for result of GetFolder being equal to "".

  15. #15
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Opening a Dialog Box for Folder Selection

    great thanks very much

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. \builtin \dialog box for folder browsing
    By horbay in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2011, 07:41 AM
  2. Different 'Browse for Folder' dialog?
    By Jon.R in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-14-2011, 02:30 PM
  3. Open file/folder dialog box
    By Jumpy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-15-2007, 09:23 AM
  4. Dialog Box upon opening
    By jamphan in forum Excel General
    Replies: 1
    Last Post: 09-26-2005, 06:05 PM
  5. Opening a dialog
    By Fredrik Wahlgren in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2005, 09:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1