Using .filesearch for text within a file

M

Michael Wise

Is there a way to search for mutiples of specific text within a .txt
file. For instance I'm needing to find a constant value "Y31" and then
a variable value at the same time like "36601". These 2 values are not
in the same line. I do want this file opened once found. I'm currently
using .filesearch and have tried various wildcards, .textorproperty
techniques but have not found a solution. Thanks for any suggestions.

Current Code (does not completely do what I want to do):

Sub FindPOFile()
Dim I As Integer
Worksheets("Data").Select
Cells.Select
Selection.ClearContents
5 si = Worksheets("Setup").Range("C4")
With Application.FileSearch
..NewSearch
..LookIn = "\\txnt34\g-tx-virtual"
..TextOrProperty = si
..MatchTextExactly = True
..Filename = "*.txt"
..Execute


For I = 1 To .FoundFiles.Count

If I = 2 Then MsgBox ("More than one file was found matching your
criteria")

Workbooks.Open .FoundFiles(I)

Next I

End With
If I = 1 Then GoTo 5

Cells.Select
Selection.Copy
Windows("Outstanding PO Tool.xls").Activate
Sheets("Data").Select
ActiveSheet.Paste
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top