Group: microsoft.public.word.vba.general
From: "fumei via OfficeKB.com"
Date: Thursday, March 13, 2008 2:02 PM
Subject: Re: How do I search for a Word style without flagging end-of-row m

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


Benjamino5 wrote:
>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.

--
Message posted via http://www.officekb.com