S
sean
Hi All.
I am using a custom SearchDocument function that receives the range and
search string as the parameters, and the function returns a Boolean. The
problem is that the function is always returning a true value.
The code is listed below:
Function SearchDocument(oRange As Range, sFind As String) As Boolean
Dim boolResult As Boolean
With oRange.Find
.ClearFormatting
.Forward = True
.MatchAllWordForms = False
.MatchCase = False
.MatchSoundsLike = False
.MatchWholeWord = False
.MatchWildcards = True
.Wrap = wdFindStop
.Text = sFind
.Execute
boolResult = .Found
End With
'MsgBox boolResult
SearchDocument = boolResult
End Function
If I pass the following search string:
"^13[! ]@.ZIP*^13[! ]@.ZIP"
The range that is being passed is the remaining content of the document.
Everytime I find the range, I move the end of the range back by one
paragraph to insure that I get the correct information. Then I copy the
range into another file and then delete everything but the line that
contains the .zip. The Output looks like:
ALLCOSTS.ZIP AT ALL COSTS
ARTFULDG.ZIP SEALS--TOP SECRET OPERATION: ARTFUL DODGER
BALPOWR1.ZIP Balance of Power
By: Tom Clancy
No synopsis available.
<end of document>
Why isn't the find failing when it gets to "BALPOWR1.ZIP Balance of Power"?
There is no more text with ".zip" starting at the beginning of the line.
Confused, Sean
I am using a custom SearchDocument function that receives the range and
search string as the parameters, and the function returns a Boolean. The
problem is that the function is always returning a true value.
The code is listed below:
Function SearchDocument(oRange As Range, sFind As String) As Boolean
Dim boolResult As Boolean
With oRange.Find
.ClearFormatting
.Forward = True
.MatchAllWordForms = False
.MatchCase = False
.MatchSoundsLike = False
.MatchWholeWord = False
.MatchWildcards = True
.Wrap = wdFindStop
.Text = sFind
.Execute
boolResult = .Found
End With
'MsgBox boolResult
SearchDocument = boolResult
End Function
If I pass the following search string:
"^13[! ]@.ZIP*^13[! ]@.ZIP"
The range that is being passed is the remaining content of the document.
Everytime I find the range, I move the end of the range back by one
paragraph to insure that I get the correct information. Then I copy the
range into another file and then delete everything but the line that
contains the .zip. The Output looks like:
ALLCOSTS.ZIP AT ALL COSTS
ARTFULDG.ZIP SEALS--TOP SECRET OPERATION: ARTFUL DODGER
BALPOWR1.ZIP Balance of Power
By: Tom Clancy
No synopsis available.
<end of document>
Why isn't the find failing when it gets to "BALPOWR1.ZIP Balance of Power"?
There is no more text with ".zip" starting at the beginning of the line.
Confused, Sean