title: Searching a File in Directory
body: <p>I would like to search a file in user-defined directory. My file structure like that <code>xxx__description__myFileName__YYMMDD.txt</code> there'll be multiple versions of this file so I want to list all files in directory which includes <code>myFileName</code> in their filename. Also I don't know is it the efficient way to list files with such type of code.</p>
  
  <p>I tried to use this code but it gives me an error:</p>
  
  <blockquote>
    <p>Run-time error '445': Object doesn't support this action</p>
  </blockquote>
  
  <pre><code>Sub findFiles()
     Dim i As Integer
     Dim myFile As String
  
     myFileName = "ABC123"
  
     With Application.FileSearch
        .NewSearch
        .LookIn = "C:\myTestDirectory"
        .fileName = "*myFileName*.xlsx"
        .SearchSubFolders = True
        If .Execute() &gt; 0 Then
           For i = 1 To .FoundFiles.Count
              Debug.Print .FoundFiles(i)
           Next i
        End If
     End With
  End Sub
  </code></pre>