Beste mensen,
Ik word hier helemaal gek van..
Ik wil een procedure schrijven die 2 woordreeksen opspoort in een aantal documenten die ergens in een map op het netwerk staan. Dus zoiets "woord1 en woord2 " EN / OF "woord3 en woord4 ".
Hieronder heb ik (sterk vereenvoudigd) de procedure neergezet.
Probleem is dat de gebruikte methodiek met Filesearch.Propertytests alleen maar één reeks vindt, de 2e reeks vindt hij domweg niet, ongeacht een OR of AND zoekvoorwaarde
Wie ziet het?? Want ik heb echt alles zo'n beetje al geprobeerd.
B.v.d.!!
ZoekRefBestanden(pRij, pDir, pZoekstring1, pZoekstring2)
Dim fs As FileSearch
Set fs = Application.FileSearch
fs.NewSearch
With fs
With .PropertyTests
.Add _
Name:="Tekst of Eigenschap", _
Condition:=msoConditionIncludesPhrase, _
Value:= pZoekstring1, SecondValue:= pZoekstring2, _
Connector:=msoConnectorOr
End With
.LookIn = pDir
.SearchSubFolders = True
.Filename = "*"
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
End With
With Application.FileSearch
If .Execute() > 0 Then
' Voert actie uit
End If
End With
''testje om de instellingen te tonen (maakt geen onderdeel uit van de procedure)
With Application.FileSearch.PropertyTests(1)
myString = "This is the search criteria: " _
& " The name is: " & .Name & ". The condition is: " _
& .Condition
If .Value <> "" Then
myString = myString & ". The value is: " & .Value
If .SecondValue <> "" Then
myString = myString _
& ". The second value is: " _
& .SecondValue & ", and the connector is" _
& .Connector
End If
End If
MsgBox myString
End With
End Sub
Ik word hier helemaal gek van..

Ik wil een procedure schrijven die 2 woordreeksen opspoort in een aantal documenten die ergens in een map op het netwerk staan. Dus zoiets "woord1 en woord2 " EN / OF "woord3 en woord4 ".
Hieronder heb ik (sterk vereenvoudigd) de procedure neergezet.
Probleem is dat de gebruikte methodiek met Filesearch.Propertytests alleen maar één reeks vindt, de 2e reeks vindt hij domweg niet, ongeacht een OR of AND zoekvoorwaarde
Wie ziet het?? Want ik heb echt alles zo'n beetje al geprobeerd.
B.v.d.!!
ZoekRefBestanden(pRij, pDir, pZoekstring1, pZoekstring2)
Dim fs As FileSearch
Set fs = Application.FileSearch
fs.NewSearch
With fs
With .PropertyTests
.Add _
Name:="Tekst of Eigenschap", _
Condition:=msoConditionIncludesPhrase, _
Value:= pZoekstring1, SecondValue:= pZoekstring2, _
Connector:=msoConnectorOr
End With
.LookIn = pDir
.SearchSubFolders = True
.Filename = "*"
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
End With
With Application.FileSearch
If .Execute() > 0 Then
' Voert actie uit
End If
End With
''testje om de instellingen te tonen (maakt geen onderdeel uit van de procedure)
With Application.FileSearch.PropertyTests(1)
myString = "This is the search criteria: " _
& " The name is: " & .Name & ". The condition is: " _
& .Condition
If .Value <> "" Then
myString = myString & ". The value is: " & .Value
If .SecondValue <> "" Then
myString = myString _
& ". The second value is: " _
& .SecondValue & ", and the connector is" _
& .Connector
End If
End If
MsgBox myString
End With
End Sub
Laatst bewerkt: