Results 1 to 10 of 10

Exclude Files from GetOpenFileName based on File Name

Threaded View

  1. #1
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Exclude Files from GetOpenFileName based on File Name

    Hi

    I've this code to present the user of a list of files to open
    ' File filters
        Filter = "Excel Files (*.xls*),*.xls*  "
        FilterIndex = 1
        ' Set DialogCaption
        Title = "Select a File to Open"
     
        ' Select Start Drive & Path
        ChDir "C:\ABC\CBA LOSE"  'You will need to change this to S:\ABC\CBA LOSE\
     
        With Application
            ' Set File Name to selected File
            fileName = .GetOpenFilename(Filter, FilterIndex, Title)
        End With
        ' Exit on Cancel
        If fileName = False Then
            MsgBox "No file was selected."
            Exit Sub
        End If
        ' Open File
        Workbooks.Open fileName
    and it presents with this screen screen capture.jpg

    I'd like the screen to NOT include any files with "Apple" in the file name. So, the fifth item on the list (Apple MTS (Template).xls) would not be displayed. ( I've tried to filter on "<> InStr(File.Name,"Apple")" with no success.

    Any way to accomplish this?
    Last edited by jaslake; 02-18-2011 at 02:18 PM.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

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