Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2007

Tip: Looking for answers? Try searching our database.

Select ... but don't scroll into view?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Klaus Linke - 04 Apr 2007 14:52 GMT
Is it possible to select something, but don't have Word automatically scroll
that something into view?

The best I came up with:
  Dim oldRange As Range
  Set oldRange = Selection.Range.Duplicate
  ActiveDocument.Characters(1).Select  ' select something else
  ActiveWindow.ScrollIntoView obj:=oldRange ' bring the old selection back
into view

... but that still moves the view a bit.

(Background: I'm writing a macro that helps users edit (specially formatted)
endnotes. The macro should work both when the endnote reference is selected,
or when the cursor already is in some endnote. In the latter case I would
like to select the endnote reference up in the text, but not have Word
scroll it into view)

Regards,
Klaus
Jean-Guy Marcil - 04 Apr 2007 19:29 GMT
Klaus Linke was telling us:
Klaus Linke nous racontait que :

> Is it possible to select something, but don't have Word automatically
> scroll that something into view?
[quoted text clipped - 13 lines]
> In the latter case I would like to select the endnote reference up in
> the text, but not have Word scroll it into view)

If you want to modify TextA while the user has TextB selected, you do not
need to select TextA as long as you have a way of knowing what TextA is.
For example, your sample code:

  Dim oldRange As Range
  Set oldRange = Selection.Range.Duplicate
  ActiveDocument.Characters(1).Select  ' select something else
  ActiveWindow.ScrollIntoView obj:=oldRange ' bring the old selection back

could be:

  Dim oldRange As Range
  Dim RefRange As Range
  Set oldRange = Selection.Range.Duplicate
  Set RefRange = ActiveDocument.Characters(1)
  With RefRange
       .Font.Bold = True
   End With
   'Etc.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Klaus Linke - 04 Apr 2007 20:51 GMT
Hi Jean-Guy,

Thank you, I might have to resort to that. I would have liked to select the
endnote reference, mostly as a visual indicator for the user about the
endnote that is currently handled by my macro.
But it is too annoying if that causes the screen to scroll.
As another work-around, I may try to appy a highlight to the endnote
reference while my macro operates on the endnote, and remove the highlight
when it finishes.

Regards,
Klaus

> Klaus Linke was telling us:
> Klaus Linke nous racontait que :
[quoted text clipped - 36 lines]
>    End With
>    'Etc.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.