How do I see the previous line when doing a Find in Word 2007

N

nidsumhelp

This seems like a dumb question, but I have spent the last hour trying to
figure that out to no avail.

I need to Find some text, and then make a decision to Replace it based on
the contents of the line directly above it. The problem is that -- if the
matching line is not in the page being viewed at the time -- Word places the
matching line at the top of the window. Hence, I cannot see what the previous
line is. Yes, I could just scroll up, but I need to make a lot of changes in
a large document, and it would be just so much faster to hold the Ctrl key
down, and then click either F (if I don't want to change) or R (if I want to
change) just by looking at the previous line -- if it was shown --, without
having to scroll up.

I tried doing the search Up and Down, but it makes no difference; the line
with tha matching content is always placed at the top. Tried Two-Page
display, same thing.

An option that would allow me to choose to have the line with thematching
content being displayed in the middle of the window would be ideal, but I
haven't found a way of doing that.

Any suggestions?

Thanks in advance for your assistance.
 
D

Doug Robbins - Word MVP on news.microsoft.com

You could use macroa macro containing the following code instead of the
Find/Replace dialog:

Dim myRange As Range
Dim prevline As Range
Dim Findstr As String
Dim Replacementstr As String
Dim Replace
Findstr = InputBox("Insert the text that you want to find.")
Replacementstr = InputBox("Insert the replacement text.")
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=Findstr, Forward:=True, _
MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False) = True
Set myRange = Selection.Range
Set prevline = Selection.Range.Duplicate
prevline.MoveStart Unit:=wdSentence, Count:=-1
prevline.Select
ActiveWindow.ScrollIntoView Selection.Range, True
Replace = MsgBox("Replace the text?", vbYesNoCancel + vbQuestion)
If Replace = vbYes Then
myRange.Text = Replacementstr
ElseIf Replace = vbNo Then
myRange.Text = myRange.Text
Else
Exit Sub
End If
Selection.Collapse wdCollapseEnd
Selection.MoveRight wdCharacter, 1
Loop
End With

--
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, originally posted via msnews.microsoft.com
 

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