Results 1 to 6 of 6

Excel VBA code for selecting a folder then search & open specified files in that folder

Threaded View

  1. #1
    Registered User
    Join Date
    09-21-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    17

    Excel VBA code for selecting a folder then search & open specified files in that folder

    Hi There,

    I'm looking for the VBA code that firsts prompts the user to select a folder where the files are stored and then searches for a specified file. The full filename does not always remain, so i need to search with a part name something like Processed-File will be present in the filename.

    I'm able to pick the folder where the files are located but not able to automatically select the file that i'm looking for

    This is the code i have got so far which isn't working;

    SourceDir = Application.FileDialog(msoFileDialogFolderPicker).Show
    SourceDir = Application.FileDialog(msoFileDialogFolderPicker).SelectedItems.Item(1)
          With Application.FileSearch
                .LookIn = "SourceDir"
                .FileType = msoFileTypeExcelWorkbooks
                .Filename = "Processed-File*.xls"
                .Execute
          End With
    Appreciate any help in completing this task

    Cheers
    Last edited by JBeaucaire; 06-19-2013 at 12:56 AM. Reason: Added CODE tags, as per Forum Rules. Take a moment to read the Forum Rules in the menu bar above. Thanks.

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