Customize FIND function with a vba macro?

B

brianrose217

I'd like to find a way to customize the FIND function, possibly with a
vba macro, so that each time Word finds the text you've specified, it
highlights it in the *middle* of the screen, scrolling the document if
necessary.

Currently, if the text does not appear on the screen already, Word
will scroll the document so that the highlighted, found text is on the
very top line.

Can I change this?
 
H

Helmut Weber

Hi,

like this:

Sub Macro2()
Dim rngDcm As Range
Set rngDcm = ActiveDocument.Range
With rngDcm.Find
.Text = "433"
If .Execute Then
rngDcm.HighlightColorIndex = wdYellow
ActiveWindow.ScrollIntoView rngDcm
End If
End With
End Sub

To show the highlighted word exactly in the center
of the screen or somewhere else is a different matter.



HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
B

brianrose217

Hi,

like this:

Sub Macro2()
Dim rngDcm As Range
Set rngDcm = ActiveDocument.Range
With rngDcm.Find
.Text = "433"
If .Execute Then
rngDcm.HighlightColorIndex = wdYellow
ActiveWindow.ScrollIntoView rngDcm
End If
End With
End Sub

To show the highlighted word exactly in the center
of the screen or somewhere else is a different matter.

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

This is along the lines of what I meant. I was looking for a way to
customize WORD's own find function so that it displayed found words in
the middle of the screen. Thanks for the suggestions. Any idea how to
do this?
 

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