• Saving Your Place while scrolling (2000 and up)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Saving Your Place while scrolling (2000 and up)

    Author
    Topic
    #430602

    The following is an extremely useful tool for authors, proofreaders, and editors. It saves the current position of your cursor on the fly and then lets you go back to that same position a little later. This is a great tool if you ever have to check an in-text citation against an end-of-document bibliography and then notice that you need to change something in the bibliography. It’s also good if you notice, halfway through reading a document, that an author inconsistently uses both “online” and “on-line” and want to do a quick search-and-replace without losing your place.

    It used to be that you could leave your cursor where it was, scroll up and down, and then just press one of the arrow keys to return to your position. With Word 2003, when you scroll, the cursor comes with you. This tool offers a simple workaround for that, too:

    Dim pos As Range
    Dim used As Boolean
    Sub SaveRange()
    Set pos = Selection.Range
    used = True
    End Sub
    Sub GoToRange()
    If Not used Then
        MsgBox "Nothing has been marked."
        Exit Sub
        End If
    pos.Select
    End Sub
    

    Make sure that the two Dim statement are at the very top of your module so that both of the Subs can access them. Then just add two buttons (and maybe shortcut keys) to your toolbar.

    The first macro saves the position of your cursor or any selection you’ve made. The second macro (re)selects the selection saved by the first macro.

    Viewing 2 reply threads
    Author
    Replies
    • #1005926

      Thanks! For others reading this: using these macros is easiest if you assign them to custom toolbar buttons and/or keyboard shortcuts.

      The code can be simplified a bit: you can test pos itself to see if it has been set:

      Dim pos As Range

      Sub SaveRange()
      Set pos = Selection.Range
      End Sub

      Sub GoToRange()
      If pos Is Nothing Then
      MsgBox "Nothing has been marked."
      Else
      pos.Select
      End If
      End Sub

    • #1006042

      Here is a slightly fancier version that lets you toggle back and forth between two locations in a document.

      Dim pos As Range

      Sub SaveRange()
      Set pos = Selection.Range
      End Sub

      Sub GoToRange()
      Dim prevpos As Range
      If pos Is Nothing Then
      Set pos = Selection.Range
      Else
      Set prevpos = Selection.Range
      pos.Select
      Set pos = prevpos
      End If
      End Sub

      • #1006735

        Thanks to you both, I didn’t even know I was missing this feature so much!

      • #1008016

        Hans

        I really like your macro – but I can only get it to work if I create it in my current document . When I create it in normal.dot, every time I run GotoRange, it spits out an error highlighting the “If pos is Nothing Then” – it’s as if it isn’t seeing the initial “Dim pos As Range” – which in the VB Editor appears associate with the previous macro (i.e. it has a line under it). Is there an easy way to fix this?

        Thanks & regards

        Neil

      • #1008017

        Hans

        Please ignore my last post – I figured it out. All I had to do was place these macros first in the module, above all other macros. But I’m not sure what I will do if I install another similarly constructed macro that has the same requirements – so if you do have any good housekeeping tips for this situation, I’d still be grateful for your advice.

        Thanks again

        Neil

        • #1008027

          The line

          Dim pos As Range

          should be at the top of the module, but the SaveRange and GoToRange macros can be anywhere in the document. Even if they are further down, the Dim pos As Range line should still be at the top, before all macros.

    • #1006798

      Hi Andy

      I use a slightly different approach, with Ctrl+Shift+T setting a temporary bookmark, and Ctrl+Shift+R returning to it. I think this has all the advantages of your approach, plus it allows you to reopen a document (even the next day) and return to the point you marked when last working on the document.

      I’m aware that pressing Shift+F5 on reopening a document works similarly, but using bookmarks is more resilient. For example:

      • they last longer (till you next press Ctrl+Shift+T); and
      • they allow you to mark a position, but do one last edit at another point in the document before closing and saving.[/list]At one point I had a more sophisticated version that worked something like this (on pressing Ctrl+Shift+T):
        • If the temporary bookmark doesn’t exist, create it.
        • If it does, offer a choice between overwriting and creating a second one.[/list]…with similar processing for Ctrl+Shift+R.

          But in the end, I decided that was too elaborate and returned to the simpler version.

      • #1008030

        Thx Andyman for triggering the topic in this post. Very handy!

        David…these are a couple of very special shortcut key combinations. I have tried it out and is extremely handy. Cheers for sharing this!

    Viewing 2 reply threads
    Reply To: Saving Your Place while scrolling (2000 and up)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: