+ Reply to Thread
Results 1 to 6 of 6

How to extract file name from user selected file via Application.FileDialog

  1. #1
    Registered User
    Join Date
    09-08-2012
    Location
    San Diego
    MS-Off Ver
    Excel 2010
    Posts
    1

    How to extract file name from user selected file via Application.FileDialog

    Hi All

    Long time reader first time poster. I am trying to figure out how to extract the file name for a user selected item via the Application.FileDialog(msoFileDialogFilePicker) method. The below code prompts the user to choose an image but i can't seem to figure out how to extract the file name into a string variable. If i set .SelectedItems(1) equal to a string variable i get an error. Any ideas? Thanks.

    Please Login or Register  to view this content.
    Last edited by Cutter; 09-08-2012 at 08:13 PM. Reason: Added code tags

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: How to extract file name from user selected file via Application.FileDialog

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    09-08-2012
    Location
    San Diego
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: How to extract file name from user selected file via Application.FileDialog

    Hi Patel45

    Thanks for the quick reply. I'm a bit of a newbie to excel programming, so please excuse my slow comprehension. The code you provided extract ALL the file names from a selected folder. Is there a way to just extract the file name for a single user selected file? Also, in your variable declarations you used the '$' character. Is that a unique naming scheme?

    Thanks

  4. #4
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: How to extract file name from user selected file via Application.FileDialog

    @ Jpdatabase

    Welcome to the forum.

    Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at the top of the page and read Rule #3.
    Thanks.

  5. #5
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: How to extract file name from user selected file via Application.FileDialog

    Please Login or Register  to view this content.
    Last edited by patel45; 09-09-2012 at 03:12 AM.

  6. #6
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: How to extract file name from user selected file via Application.FileDialog

    Also, in your variable declarations you used the '$' character. Is that a unique naming scheme?
    I don't know whether "unique" is the right word, just different. Have a look at the link below where it lists the type declaration characters with a bit of explanation.

    http://support.microsoft.com/kb/191713
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

+ 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