Can't get range to MoveEnd and MoveStart correctly

E

Ed

I'm trying to find some text in my Range, then use MoveEnd and MoveStart to
encompass everything from the end point to the beginning of the document.
To check what was happening, I selected the range and turned the text green.
All that was green was the very last paragraph mark! Can someone help me
fix this?

' Find end of TIR
Set rngTIR = rngDoc
rngTIR.Find.Execute _
FindText:="DA Form XXXX-E: "
' Move range to cover all of TIR
rngTIR.MoveEnd Unit:=wdParagraph
' If header exists, move range to include
If bolUncl = True Then
rngTIR.MoveEnd Unit:=wdParagraph, Count:=3
End If
rngTIR.MoveStart Unit:=wdStory

' *****************
' Debugging only!!
rngTIR.Select
Selection.Font.ColorIndex = wdBrightGreen
Selection.Collapse Direction:=wdCollapseEnd
If MsgBox("Is this right?", vbYesNo) = vbYes Then
Selection.Font.ColorIndex = wdAuto
End If
' *****************
 
P

Peter Hewett

Hi Ed

Just change:
rngTIR.MoveStart Unit:=wdStory
to:
rngTIR.MoveStart wdStory, -1

HTH + Cheers - Peter
 
E

Ed

Thank you, Peter! That worked beautifully!

Now I've noticed the MoveEnd did *NOT* seem to include the last paragraph
mark. When the text was made green, all but the last paragraph mark at the
end of the last line was changed. Does rngTIR.MoveEnd Unit:=wdParagraph,
Count:=3 only move UP TO the mark? Do I need to change it? Or maybe add a
MoveEnd wdCharacter or something?

Ed
 
E

Ed

Never mind, Peter. I just looked over my Debug Only code. When I change
the font color back, my Selection point is still covering only the last
mark - I haven't reselected the entire range.

Ed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top