Saturday, August 8, 2020

Find a Filename from folder path

 Public Function fnFindFileFromPath(SearchPath, SearchFileName, dataSht) As String

    Dim StrFile As String

    'Debug.Print "in LoopThroughFiles. SearchPath: ", SearchPath

 '   StrFile = Dir(SearchPath & "\*" & SearchFileName)

    StrFile = Dir("D:\Test\")

     While (StrFile <> "")

      If InStr(StrFile, "Test") > 0 Then

         MsgBox "found " & StrFile

         Exit Function

      End If

     StrFile = Dir

    Wend

End Function

No comments:

Post a Comment