+ Reply to Thread
Results 1 to 7 of 7

Application.FileDialog(msoFileDialogFolderPicker) display InitialFileName in Folder Name

  1. #1
    Registered User
    Join Date
    07-20-2015
    Location
    Netherlands
    MS-Off Ver
    Win10, Off2019-365
    Posts
    44

    Application.FileDialog(msoFileDialogFolderPicker) display InitialFileName in Folder Name

    Hello,

    As many of you, I have used Application.FileDialog(msoFileDialogFolderPicker) many times to allow the user to select a folder on the system.

    For the solution I am currently working on, I'd like the InitialFileName to show in the Folder Name field as if it was already selected.
    By default this field is empty when I use the InitialFileName. Is there a way to achieve this or are there other solutions?

    msoFileDialogFolderPicker_InitialFileName.jpg
    Attached Images Attached Images

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Application.FileDialog(msoFileDialogFolderPicker) display InitialFileName in Folder Na

    Hello BartH_NL,

    Here is an example...

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Application.FileDialog(msoFileDialogFolderPicker) display InitialFileName in Folder Na

    Sure. Here's my example. Copy/Paste the code at the bottom of this post into a new module then run TestTheFolderPicker. (If it works, you can delete the "TestTheFolderPicker" sub and call the fnstrFolderPicker from elsewhere in your project)

    Please Login or Register  to view this content.
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  4. #4
    Registered User
    Join Date
    07-20-2015
    Location
    Netherlands
    MS-Off Ver
    Win10, Off2019-365
    Posts
    44

    Re: Application.FileDialog(msoFileDialogFolderPicker) display InitialFileName in Folder Na

    Hi Leith and mc84Excel,

    Thank you for your contribution. Nevertheless, we are not there yet. I'll explain:

    With this code

    Please Login or Register  to view this content.
    The resulting Dialog is this:

    Attachment 649833
    Notice the Folder name field is empty.

    When I hit OK, the path is passed to the Folder variable and into the msgbox, so although the selected folder is not displayed in the Folder name field, the output is correct.

    To have the folder name reflected in the Folder name field, I have to select "Documents" in the top Path field:

    Attachment 649837
    Notice now the Folder name field is filled with Documents.

    When I hit OK, again the result is correct.

    So my question remains, how can I "automate" the "manual selection" of the selected folder to have it displayed in the Folder name field.

    (The reason why I want this, is because I have noticed some users get confused when they have to hit the OK button while the Folder name field is still empty…
    I think it is not as user-friendly as I like my projects to be.)

    For who is interested, I have found another oddity:

    When I change the given Path string like this:
    Path = Application.DefaultFilePath

    Please Login or Register  to view this content.
    The resulting Dialog looks like the perfect solution, but when the user hits the OK button, it gives an error:

    Attachment 649842

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,467

    Re: Application.FileDialog(msoFileDialogFolderPicker) display InitialFileName in Folder Na

    Hi there,

    I haven't studied this in too much detail, but I think that the closest you will be able to get to what you want is to have the FullName of the initial folder displayed in the TitleBar of the DialogBox:

    Please Login or Register  to view this content.

    Hope this helps.

    Regards,

    Greg M

  6. #6
    Registered User
    Join Date
    07-20-2015
    Location
    Netherlands
    MS-Off Ver
    Win10, Off2019-365
    Posts
    44

    Re: Application.FileDialog(msoFileDialogFolderPicker) display InitialFileName in Folder Na

    Hi Greg,

    Thnks, good suggestion!

    Grtz Bart

  7. #7
    Registered User
    Join Date
    07-20-2015
    Location
    Netherlands
    MS-Off Ver
    Win10, Off2019-365
    Posts
    44

    Re: Application.FileDialog(msoFileDialogFolderPicker) display InitialFileName in Folder Na

    Hello,

    At a request from the forum's moderators, I have added an example worksheet:

    msoFileDialogFolderPicker_Excample.xlsm

    Grtz Bart

+ 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. [SOLVED] Application.FileDialog(msoFileDialogFolderPicker) looping?
    By Andrew Entee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-10-2017, 05:57 PM
  2. [SOLVED] end if cancel clicked on .FileDialog(msoFileDialogFolderPicker).Show
    By dedark05 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-21-2016, 09:35 PM
  3. Show Files in Folder using Application.FileDialog(msoFileDialogFolderPicker)
    By rtcwlomax in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-05-2015, 09:53 AM
  4. [SOLVED] Specific folder when opening windows popup folder selection with msoFileDialogFolderPicker
    By trizzo in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-18-2015, 11:05 AM
  5. VBA to show excel files inside a folder Application.FileDialog(msoFileDialogFolderPicker)
    By Paul Cherian in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-03-2014, 08:17 AM
  6. Replies: 1
    Last Post: 07-11-2013, 05:01 PM
  7. [SOLVED] FileDialog(msoFileDialogFolderPicker) not using the current direct
    By nx3 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2006, 08:25 AM

Tags for this Thread

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