• .Filesearch problem (2000)

    Author
    Topic
    #364141

    I am having a problem with an application that I have written that uses multiple file searches. I do one file search at the beginning of the code execution in one file path and then I want to do another file search later in the execution in a different file path. I was testing my application and it was not performing as I expected. It was not finding the file I knew was in the directory of the second file search. While stepping through the code, I noticed that the .lookin value was not changing to the path after the “=” in my second .filesearch. I read in the help to use .newsearch to reset the .filesearch attributes, however it also states it does not reset the .lookin attribute.

    Does anyone know how to get the second .filesearch to look in the new file path?

    Here is a segment of the code.

    With Application.FileSearch
    .NewSearch
    .LookIn = gstrArchive_Path
    .Filename = mstrFile_Name

    If .Execute > 0 Then
    Exit Sub
    End If

    End With

    The .lookin is not changing to the “gstrArchive_Path” when I step through the code. It is still pointing to the first file path on the first .filesearch.

    Viewing 0 reply threads
    Author
    Replies
    • #558104

      Mark

      Maybe you can try to change the Excel current directory by doing something like:

      ChDrive gstrArchive_Path and then a ChDir gstrArchive_Path.

      I looked into the MSKB and did not find anything useful, but you may want to look at Q259738

      Wassim

      • #558139

        Wassim,

        Thanks for the tip. It did work. It is just curious that the .lookin did not change to the new file path after I explicitly set it equal to another file path.

    Viewing 0 reply threads
    Reply To: Reply #558139 in .Filesearch problem (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel