Consulting

Results 1 to 6 of 6

Thread: Solved: Confirming filename found after wildcard search

  1. #1
    VBAX Regular
    Joined
    Dec 2007
    Posts
    78
    Location

    Solved: Confirming filename found after wildcard search

    With Application.FileSearch

    .LookIn = "O:\NGMData7\Reserved\IT Library\Scheduling\Resource Allocations\Resource Allocations Spreadsheet"
    .Filename = "Resource Allocations*.xls"

    Application.StatusBar = "Please be patient..."

    If .Execute > 0 Then
    Hello all, assuming .Execute is greater than 0, how do I then extract the name of a/the file (i.e not the path) that I have successfully found (during the wildcard match)?

    I could work out how to do this using a text extract formula but it seems long winded and I wondered if I'm just missing a property.

    Thanks.

  2. #2
    VBAX Regular
    Joined
    Dec 2007
    Posts
    78
    Location
    Would still be interested if a property exists but I solved this by extracting the filename using...
    filenamestring = Mid(.FoundFiles(1), InStrRev(.FoundFiles(1), "\") + 1)

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    No, that is the way to do it.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Regular
    Joined
    Dec 2007
    Posts
    78
    Location
    thankyou

  5. #5
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    There's no property but there is another way - Dir.
    [vba]
    filenamestring = Dir(.FoundFiles(1))
    [/vba]
    Last edited by Norie; 02-26-2008 at 08:48 AM.

  6. #6
    VBAX Regular
    Joined
    Dec 2007
    Posts
    78
    Location
    Thanks, I'll try that once I've retyped the entire macro (must remember to save files as a specific filename in order to prevent absent-mindedly pressing "No" as a response to "Do you want to save changes to Book1?")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •