Results 1 to 6 of 6

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

Threaded View

  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.

    With Application.FileDialog(msoFileDialogFilePicker)
             .AllowMultiSelect = False          
             .InitialFileName = CurDir         
             .Filters.Clear                   
             .Filters.Add Description:="Images", Extensions:="*.jpg", Position:=1
             .Title = "Choose image"
             If .Show = -1 Then thefile = .SelectedItems(1) Else thefile = 0
        End With
    Last edited by Cutter; 09-08-2012 at 08:13 PM. Reason: Added code tags

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