View Single Post
 
Old 10-30-2016, 12:31 AM
diracsbracket diracsbracket is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Aug 2014
Posts: 5
diracsbracket is on a distinguished road
Default How to avoid find.execute moving focus and restore exact view after search

Hi,
I have a sub that inserts a hyperlink to the heading matching the selected text in MS Word 2013.
The header's range is found using:

HTML Code:
Selection.Find.Execute
Before doing that, I save the current range (i.e. that of the selected text) in order to restore it after the search has found the heading's range.

Although the range is restored correctly (and I'm back at the selected text), usually the view of the page is shifted, as if it was scrolled up or down a bit.

Since these shifts are sometimes large, I find them annoying enough to want to avoid this.

Is that possible?
I tried this by saving/restoring various built-in MS Word bookmark ranges, for example:

HTML Code:
ActiveDocument.Bookmarks("\page").Range
But this still causes shifts....

The thing is that the find.execute moves the focus to the heading found. Is there a way to disable this focus change?

Thanks!
Reply With Quote