+ Reply to Thread
Results 1 to 2 of 2

Application . filesearch doesn't work

  1. #1
    somethinglikeant
    Guest

    Application . filesearch doesn't work

    Hi,

    Has anybody else experienced problems using application.filesearch
    My code looks something like this:-

    Sub FileListSearch()
    Call Clear
    Dim searchtext As String, qfile As String: qsearchtext = [G5]
    [C6].Select
    Do Until IsEmpty(ActiveCell)
    qfolder = ActiveCell.Value
    qfile = ActiveCell.Offset(1, 0)
    With Application.FileSearch
    .NewSearch
    .LookIn = qfolder
    .MatchTextExactly = False
    .Filename = qfile
    .TextOrProperty = qsearchtext
    .SearchSubFolders = False
    .FileType = msoFileTypeExcelWorkbooks
    If .Execute > 0 Then
    For i = 1 To .FoundFiles.Count
    ActiveSheet.Hyperlinks.Add Anchor:=Cells(13 + i,
    3), Address:= _
    .FoundFiles(i), TextToDisplay:= _
    Replace(.FoundFiles(i), qfolder & "\", "")
    Next i
    End If
    End With
    ActiveCell.Offset(1, 0).Select
    Loop
    End Sub

    However whenever I search for a specific reference, In my case a cheque
    number it appears in some but not all of the workbooks I expected it to
    appear in.
    Is there something I need to be careful about with the type of data
    is qsearchtext to be defined as an integer, or string?
    I can see the cheque number in one of the spreadsheets but it doesn't
    come outusing vba code.
    As well as this I tried a search using XP explorer and no results
    either.
    Am I missing a trick here?
    Has anyone else overcome these problems using .filesearch.

    Any help appreciated

    thanks

    somethinglikeant


  2. #2
    Jim Rech
    Guest

    Re: Application . filesearch doesn't work

    Excel files are not text files, they are binary files. Numbers are recorded
    in binary format, not literal strings. Maybe if you enter the check numbers
    in cells as text this might work, but you'd have to be alert to the
    possibility of false positives.

    --
    Jim
    "somethinglikeant" <[email protected]> wrote in message
    news:[email protected]...
    | Hi,
    |
    | Has anybody else experienced problems using application.filesearch
    | My code looks something like this:-
    |
    | Sub FileListSearch()
    | Call Clear
    | Dim searchtext As String, qfile As String: qsearchtext = [G5]
    | [C6].Select
    | Do Until IsEmpty(ActiveCell)
    | qfolder = ActiveCell.Value
    | qfile = ActiveCell.Offset(1, 0)
    | With Application.FileSearch
    | .NewSearch
    | .LookIn = qfolder
    | .MatchTextExactly = False
    | .Filename = qfile
    | .TextOrProperty = qsearchtext
    | .SearchSubFolders = False
    | .FileType = msoFileTypeExcelWorkbooks
    | If .Execute > 0 Then
    | For i = 1 To .FoundFiles.Count
    | ActiveSheet.Hyperlinks.Add Anchor:=Cells(13 + i,
    | 3), Address:= _
    | .FoundFiles(i), TextToDisplay:= _
    | Replace(.FoundFiles(i), qfolder & "\", "")
    | Next i
    | End If
    | End With
    | ActiveCell.Offset(1, 0).Select
    | Loop
    | End Sub
    |
    | However whenever I search for a specific reference, In my case a cheque
    | number it appears in some but not all of the workbooks I expected it to
    | appear in.
    | Is there something I need to be careful about with the type of data
    | is qsearchtext to be defined as an integer, or string?
    | I can see the cheque number in one of the spreadsheets but it doesn't
    | come outusing vba code.
    | As well as this I tried a search using XP explorer and no results
    | either.
    | Am I missing a trick here?
    | Has anyone else overcome these problems using .filesearch.
    |
    | Any help appreciated
    |
    | thanks
    |
    | somethinglikeant
    |



+ 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