C
Chip Orange
Hi all,
I'm using the .find method of a range object to locate highlighted text.
I have a document with highlighted text, which does not open showing that
it's damaged in any way, yet the .find acts differently with this document,
and I'd like to know if there's an unusual circumstance here I can program
around, or if this is undetected corruption.
Normally the range object is reset to point to the found text. In this
case, the range object is not being reset, but the .find.execute method is
returning TRUE.
Without the range object being reset I cannot deal with what I found.
Here's the relevant portion of the program below in case I'm doing something
in a way that only sometimes works:
With objCurPortionRange.Find
..ClearFormatting
..Format = True
..Highlight = True
..Text = ""
..Wrap = wdFindStop
End With
I = objCurPortionRange.Start
' loop through all blocks of highlighted text in this range
Do While objCurPortionRange.Find.Execute()
' found some highlighted text.
objCurPortionRange.Collapse wdCollapseStart
If objCurPortionRange.Characters.First.HighlightColorIndex = wdNoHighlight
Then
MsgBox "find failed to locate highlighted text, but returned true"
objCurPortionRange.Select
Exit Function
End If
thanks for any help.
Chip
I'm using the .find method of a range object to locate highlighted text.
I have a document with highlighted text, which does not open showing that
it's damaged in any way, yet the .find acts differently with this document,
and I'd like to know if there's an unusual circumstance here I can program
around, or if this is undetected corruption.
Normally the range object is reset to point to the found text. In this
case, the range object is not being reset, but the .find.execute method is
returning TRUE.
Without the range object being reset I cannot deal with what I found.
Here's the relevant portion of the program below in case I'm doing something
in a way that only sometimes works:
With objCurPortionRange.Find
..ClearFormatting
..Format = True
..Highlight = True
..Text = ""
..Wrap = wdFindStop
End With
I = objCurPortionRange.Start
' loop through all blocks of highlighted text in this range
Do While objCurPortionRange.Find.Execute()
' found some highlighted text.
objCurPortionRange.Collapse wdCollapseStart
If objCurPortionRange.Characters.First.HighlightColorIndex = wdNoHighlight
Then
MsgBox "find failed to locate highlighted text, but returned true"
objCurPortionRange.Select
Exit Function
End If
thanks for any help.
Chip