Use VBA to bring cursor into viewed text

  • Assume that a Word user has scrolled down the document to some location, but the cursor (text insertion point) is not within the text being viewed.


    How can VBA be used to identify the location of the currently viewed text, and to bring the cursor into this text?

  • As for me, I first need to understand what you mean.


    Scenario:


    I scroll down to page 3 using my scroll bar. My insertion point is still back at page 1.


    You want VBA to bring the insertion point to the currently viewed area?


    I'm feeling like that's pretty tough to determine.


    1. What if the viewed area contains a graphic? Do you want it selected?


    2. What if I scroll really fast?


    3. Should the insertion point be moved to the top or bottom of the viewable area? Center?


    4. Isn't it easier to just click when you're done scrolling?


    I really feel that trying to implement this would cause problems beyond believe. It would constantly have to be "active", and what happens when you just want to scroll down to see page 2's header and go back and fix page 1's header? Then, my insertion point move, and I've got to go find where I was at again?


    If you can tell us the purpose of using such code, perhaps we can provide a way to get around whatever difficulty you're trying to work around, or some other way to accomplish the task besides what you suggest.


    :)

  • Thanks for your response...
    The scenario is like this:


    Dilbert is in his cubicle, reading a Word document that is slowly "Autoscrolling" up the screen. His left hand rests casually near the corner of the keyboard, one finger on the "CTRL" key and another on the "Z" key.


    When the boss appears on the radar, Dilbert presses "CTRL+Z". A macro finds out where he was reading, bookmarks the place, closes the file, and opens a boring document about projections for the next quarter's widget sales.


    When the 'all clear' sounds, he goes back to the document, and Document.Open takes him right to the place where he left off...

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!