View Single Post
  #4   Report Post  
Posted to microsoft.public.word.newusers
Klaus Linke Klaus Linke is offline
external usenet poster
 
Posts: 413
Default "Go to" doesn't show new location of cursor

"christophercbrewster via OfficeKB.com" u3143@uwe schrieb im Newsbeitrag
news:8d15f5f6fe17b@uwe...
Klaus-- Word 2003, Windows XP. I have several routines that would leave
the
user in a different place than where he started, which is annoying. So I
plant a bookmark, TempBkmk, and return to it. Below is one of the shortest
of
these, which toggles showing and hiding the field codes. As I say, this
works
at least half the time, but I don't see what makes it fail.

Sub ToggleShowFields()
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="TempBkmk"
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
Selection.GoTo What:=wdGoToBookmark, Name:="TempBkmk" ' Return
to
original location
End Sub



Yes, that's annoying!! As far as I remember older versions, that behaviour
got worse in recent years.
It happens quite often now that after something I do -- like your toggling
"show field codes", or toggling between Outline and Layout and Normal view,
or other things -- I suddenly I don't see the text I was working on.
My usual (non-macro) way to deal with it is to use Shift+Right, Shift+Left
to bring the Selection into view again.

In your macro, you could use the work-around from my last post, and as long
as your macro doesn't mess with the Selection, you don't need the bookmark:

Sub TestGotoBM2()
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
ActiveWindow.ScrollIntoView Selection.Range
End Sub

Regards,
Klaus