Return to cursor position

A

Alan F.

Could anybody help me with this?
I write quite a few simple macros that work ok. Now I want to write
one that simply globally removes any highlighting from text I have
set. That's not the problem, but I want the document to remain where
it is on the screen, i.e. remember the cursor poition, carry out the
changes and redisplay the original page. At the moment the cursor just
goes to the last page. Anybody help?

Sub remove_highlights()
Application.ScreenUpdating = False
Selection.WholeStory
Selection.Range.HighlightColorIndex = wdNoHighlight
End Sub

Regards Alan F.
 
J

Jean-Guy Marcil

Hi Alan,

Try this:

Sub remove_highlights()
Dim CursorPos As Range

Set CursorPos = Selection.Range

Application.ScreenUpdating = False

Selection.WholeStory
Selection.Range.HighlightColorIndex = wdNoHighlight
CursorPos.Select

Application.ScreenRefresh
Application.ScreenUpdating = True

End Sub


--
Cheers!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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