ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple criteria Filesearch function (https://www.excelbanter.com/excel-programming/310883-multiple-criteria-filesearch-function.html)

Michael Wise[_14_]

Multiple criteria Filesearch function
 

Hello all,
I'm needing to search txt files for specific txt. The delima i'm havin
is one critieria is dynamic the other established. I have pasted th
code below that is not working for me but should give you an idea o
what i'm looking for.

Dim usid as string
With Application.FileSearch
.NewSearch
.LookIn = "\\txnt34\g-tx-virtual"
.TextOrProperty = usid & "EQSERVICEMAC" Here is my problem are
it does not see the string usid
.MatchTextExactly = False
.Filename = "*.txt"
.Execute

For i = 1 To .FoundFiles.Count
If .FoundFiles.Count = 0 Then GoTo Wait Else
Workbooks.Open .FoundFiles(i)
Next i
End Wit

--
Michael Wis
-----------------------------------------------------------------------
Michael Wise's Profile: http://www.excelforum.com/member.php...nfo&userid=699
View this thread: http://www.excelforum.com/showthread.php?threadid=26236


keepITcool

Multiple criteria Filesearch function
 
i dont see DOTS within the With/End With construct..

with application.filesearch
..newsearch
..lookin
..execute
end with

if you haven't set option explicit your code might run
but it's NOT setting fileSearch properties but creating variables.



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


Michael Wise wrote:


Hello all,
I'm needing to search txt files for specific txt. The delima i'm

having
is one critieria is dynamic the other established. I have pasted the
code below that is not working for me but should give you an idea of
what i'm looking for.

Dim usid as string
With Application.FileSearch
NewSearch
LookIn = "\\txnt34\g-tx-virtual"
TextOrProperty = usid & "EQSERVICEMAC" Here is my problem area
it does not see the string usid
MatchTextExactly = False
Filename = "*.txt"
Execute

For i = 1 To .FoundFiles.Count
If .FoundFiles.Count = 0 Then GoTo Wait Else
Workbooks.Open .FoundFiles(i)
Next i
End With





All times are GMT +1. The time now is 12:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com