Can you use the Len() of the range. I imagine that if the found range is
just the end of row marker, it will have a length of (probably) not more
than 1 while the ranges upon which you want to act, would have a length
somewhat greater than that.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
Doug, I think that could work! I have yet another question, though (thanks
for your patience).
How do I get the range in the first place? I'm not too familiar with the
Find object, but here's my code:
________
If s.InUse = True And s.Type = 1 And Not IsInList(s.NameLocal, whitelist) Then
wd.app.options.DefaultHighlightColorIndex = 6 'wdRed
With adoc.range.Find
.ClearFormatting()
.Text = ""
.Style = s.NameLocal
.Replacement.Highlight = True
.Replacement.Text = ""
.Execute(Replace:=2, Format:=True) 'wdReplaceAll
If .Found = True Then
' I need to check the range here, but how?
' add the name to the foundList and log
' if it's not in there already
If Not foundList.Contains(s.NameLocal + ",")
Then
foundList = foundList + s.NameLocal + ","
End If
End If
End With
End If
> Can you use the Len() of the range. I imagine that if the found range is
> just the end of row marker, it will have a length of (probably) not more
> than 1 while the ranges upon which you want to act, would have a length
> somewhat greater than that.
Doug Robbins - Word MVP - 13 Mar 2008 02:44 GMT
This highlights text to which the Heading 1 style has been applied, but does
not highlight the end of row marker even if it has that format.
Dim myrange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Heading 1")
With Selection.Find
Do While .Execute(findText:="", Forward:=True, _
MatchWildcards:=False, Wrap:=wdFindStop) = True
Set myrange = Selection.Range
myrange.HighlightColorIndex = wdRed
Selection.Collapse wdCollapseEnd
Loop
End With

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Doug, I think that could work! I have yet another question, though (thanks
> for your patience).
[quoted text clipped - 35 lines]
>> than 1 while the ranges upon which you want to act, would have a length
>> somewhat greater than that.
fumei - 13 Mar 2008 20:02 GMT
Hi Benjamin05,
"How do I get the range in the first place? I'm not too familiar with the
Find object"
You get the range in the first place by simply using it. The .Find method of
Range resizes the range itself with every find Found.
IF the found is the end-of-row marker, then you can in fact test for that.
The end-of-row marker is an odd duck and is made up of Chr(13) and Chr(7), in
that order. Note this is also the same as the end-of-cell marker.
BTW: I would make a Range object and use the Find on that, rather than adoc.
Range.Find. Let's say r.
Function IsCellMarker(strIn As String) As Boolean
If Len(strIn) = 2 And _
Asc(strIn) = 13 And _
Asc(Right(strIn, 1)) = 7 Then
IsCellMarker = True
End Function
Dim r As Range
Set r = adoc.Range
With r.Find
.....yadda yadda
Do While .Execute (yadda yadda - BTW: using Do is a better way)
' remember r (the Range itself) is actually resized
If IsCellMarker(r.Text) Then
' skip it and continue
>Doug, I think that could work! I have yet another question, though (thanks
>for your patience).
[quoted text clipped - 30 lines]
>> than 1 while the ranges upon which you want to act, would have a length
>> somewhat greater than that.