+ Reply to Thread
Results 1 to 7 of 7

MsgBox - path to folder

  1. #1
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Vietnam
    MS-Off Ver
    Excel 2010
    Posts
    382

    MsgBox - path to folder

    A rather simple problem for all the experts here I believe ^^

    I am looking for a way to prompt a messagebox which lets the user choose a folder which later will be processed in a macro. however, due to the nature of that following macro, I need the path as a text string.
    Is there any way to let excel generate a msgbox to select the folder as well display the path as text?

    Thanks,
    A2k

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: MsgBox - path to folder

    A few lines to try:
    Please Login or Register  to view this content.

    If you need more finite controls, try this:
    http://www.vbaexpress.com/kb/getarticle.php?kb_id=284
    Last edited by JBeaucaire; 08-09-2009 at 02:22 AM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Vietnam
    MS-Off Ver
    Excel 2010
    Posts
    382

    Re: MsgBox - path to folder

    thanks, but that is not "exactly" what I was looking for.
    I already checked VBAexpress but could not find any help, that why I posted here in the first place.

    I need a MSGBOX which has a button to start the folder(!) lookup, not a specific file. Further, the path should be shown within this messagebox and then by clicking OK I need it to hand over the strPath variable.

    Thanks!
    A2k


    EDIT:
    Something like this:
    Please Login or Register  to view this content.
    just, how can I add a search button to start the GetOpenFilename application?
    Last edited by Armitage2k; 08-09-2009 at 02:53 AM.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: MsgBox - path to folder

    I think the VBAX article is exactly what you want, I don't understand why you would want a MsgBox dialog with a button to invoke "get the folder"

    Using the VBAX Function BrowseForFolder (residing in a Module in your file) - something like:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Vietnam
    MS-Off Ver
    Excel 2010
    Posts
    382

    Re: MsgBox - path to folder

    Sorry folks, but this is no help.

    As I mentioned twice by now, I NEED a Msgbox which has a search button to get the folder. I know about the VBAX function, I know that a messagebox usually is not necessary, but as I mentioned before as well, due to the nature of my macro, I MUST have a msgbox with this setup. Reason why: if the user clicks cancell, my macro will not end, it will use a standard folder to import the data and write in the log that the user has imported 0 files at that moment.

    OK anyway, I am almost at the end with my code since I found some bits and pieces all over the net by now.

    Just one very easy question I would need your help on please:
    Which application do I have to start to open/select a FOLDER, not files?

    thanks,
    A2k
    Last edited by Armitage2k; 08-09-2009 at 03:16 AM.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: MsgBox - path to folder

    Armitage2k, I would strongly recommend revising your tone...

    If you view the code in the VBAX function will you discover it returns a Folder path not a File Path... the code I gave you generates a MsgBox with OK/Cancel - if OK is clicked it launches the Folder browser window (by means of utilising the VBAX Function), it then subsequently generates a 2nd MsgBox which displays the Folder Path selected in the previous dialog... the code I gave exits the routine on Cancel however you can alter this to do what you want.. ie initialise strPath but default to your default folder ... set the code to invoke the Function BrowseForFolder() only if initial MsgBox results is vbYes (ie vbCancel results in this section of code being skipped - thus default strPath remains)

    Remember that MsgBox dialogs are constrained to certain types - I would recommend browsing for material, eg: http://msdn.microsoft.com/en-us/library/139z2azd.aspx

    If you want to create Customised Dialogs you need to create User Forms.

    On an aside given the nature of your prior post I have no inclination to continue on this thread, I'm sure others will continue to assist you going forward.
    Last edited by DonkeyOte; 08-09-2009 at 03:23 AM.

  7. #7
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Vietnam
    MS-Off Ver
    Excel 2010
    Posts
    382

    Re: MsgBox - path to folder

    @donkey dont get me wrong, no insult, but I simply have asked for something and got something different. Anyway, all the help is appreciated.

    EDIT:
    Done, found another way.
    A2k
    Last edited by Armitage2k; 08-09-2009 at 03:51 AM. Reason: got it myself

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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