FindNext autoscroll to middle?

J

John Keith

Using Office2003's Word (fully updated and patched)...

I have a 100 page document that has hard-returns all through out. I can't
do a replace all ^p with "" because this would mess up numerous sections and
headers.

With the find feature open to do the replacement... I can press "F" to
navigate to the next hard-return then if it is one I need to replace press
"Alt-R" this works well except that the find eventually will be the last line
on the screen and I need to see the lines both above and below the newly
found hard-return to make the decision to replace or not.

I tried using the scroll-lock key to keep the cursor in the middle of the
screen, but this does not work.

Is there a feature I can turn on to acheive what I am looking for?
Perhaps a macro function that would scroll the screen after a find (is there
an event for this?) to place the line where the cursor is positioned to
aproxamately the middle of the screen?
 
J

John Keith

Problem solved... using ActiveWindow.ScrollIntoView method.

Add a command button on one of the tool bars to run this macro. Start by
putting the cursor before the first hard-return to erase, then click the
toolbar button. Keep doing this until you see that the next hard-return
should be skipped. Use the right arrow to deselect and move the cursor past
the hard-return. Then click the toolbar button again.

The macro replaces the next hard-return with nothing. Then positions the
selection on the newly-next hard-return. Then, If 1000 characters beyond that
hard-return would included characters that are not in the viewed area of the
window, it scrolls this selection away from the bottom of the window. As a
bonus, using a macro to control the find-replace operation prevents the
find-replace popup dialog box from getting in the way too.

Sub ZapSelectedPara()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
s = Selection.Start
Set R = ActiveDocument.Range(Start:=s, End:=s + 1000)
ActiveWindow.ScrollIntoView R, True
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
End Sub
 

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