• How to go to last edit in Word .docx docs

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » How to go to last edit in Word .docx docs

    Author
    Topic
    #480043

    I’m running Word 2007.

    When I open a .doc file, I can jump to the last edit (even from a prior session) by pressing Shift + F5.

    This does not work in a .docx file. Is there a different shortcut, or a way to add the Shift + F5 shortcut for .docx?

    Many thanks.

    Viewing 5 reply threads
    Author
    Replies
    • #1306720

      Hi krsmav,

      the docx format doesn’t store the last-edit location. However, I’ve written some macros that achieve much the same thing. See: http://www.vbaexpress.com/forum/showthread/?t=37085

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

    • #1306726

      OK, here’s the essence of the link’s content:

      In Word 97-2003, pressing Shift-F5 allows you to quickly return to the last-edited location in a document when you re-open it. It’s not 100% reliable, however. The docx format introduced with Word 2007 does not store that data and, so, this functionality is not available in the later versions.

      If you add the following code to your Normal template’s ‘This Document’ module, it will enable you to tell Word whether to store a ‘return to’ location in each document for you to return to next time you open it. Unlike the Shift-F5 approach (which only works in Word 97-2003 .doc format documents), the ‘return to’ location isn’t necessarily an editing location – it’s the start of whatever range is selected when the document is closed.

      Code:
      Private Sub Document_Open() 
          With ActiveDocument 
              If .Bookmarks.Exists("_DocClose") Then 
                  If MsgBox(Prompt:="Return to stored location?", _ 
                  buttons:=vbYesNo, Title:="Resume Location") = vbYes Then 
                      .GoTo What:=wdGoToBookmark, Name:=.Bookmarks("_DocClose") 
                      .Bookmarks("_DocClose").Select 
                      Selection.Collapse 
                  End If 
              End If 
          End With 
      End Sub
      
      Private Sub Document_Close() 
          Dim bSaved As Boolean, bRtn 
          With ActiveDocument 
              If .Name Like "Document#*" And .Saved = True Then Exit Sub 
              bSaved = .Saved 
              If .Bookmarks.Exists("_DocClose") Then 
                  bRtn = MsgBox(Prompt:="Save current location for next time?" & vbCr & _ 
                  "Yes to update 'return to' location" & vbCr & _ 
                  "No to delete previous 'return to' location" & vbCr & _ 
                  "Cancel to retain previous 'return to' location", _ 
                  buttons:=vbYesNoCancel, Title:="Resume Location") = vbYes 
              Else 
                  bRtn = MsgBox(Prompt:="Save current location for next time?", _ 
                  buttons:=vbYesNo, Title:="Resume Location") = vbYes 
              End If 
              If bRtn = vbYes Then _ 
              .Bookmarks.Add Name:="_DocClose", Range:=Selection.Range.Characters.First 
              If bRtn = vbNo Then _ 
              If .Bookmarks.Exists("_DocClose") Then .Bookmarks("_DocClose").Delete 
              If bSaved = True And .Saved = False Then .Save 
          End With 
      End Sub 

      After saving the Normal template, exiting & restarting Word, whenever you close a document you’ll be given the option to store a ‘return to’ location for it. Similarly, whenever you open a document with as stored ‘return to’ location, you’ll be given the option of returning to that location. The ‘return to’ location is held in a hidden bookmark, named “_DocClose”. Being hidden, that bookmark is not normally visible. Whilst it might be vulnerable to accidental deletion, I think that’s of little consequence in a document that’s being edited, as you get the opportunity to recreate it on exit.

      Here’s some alternative code, that avoids the prompts given by the above code:

      Code:
      Private Sub Document_Open() 
          With ActiveDocument 
              If .Bookmarks.Exists("_DocClose") Then 
                  .GoTo What:=wdGoToBookmark, Name:=.Bookmarks("_DocClose") 
                  .Bookmarks("_DocClose").Select 
                  Selection.Collapse 
              End If 
          End With 
      End Sub 
      
      Private Sub Document_Close() 
          Dim bSaved As Boolean 
          With ActiveDocument 
              If .Name Like "Document#*" And .Saved = True Then Exit Sub 
              bSaved = .Saved 
              .Bookmarks.Add Name:="_DocClose", Range:=Selection.Range.Characters.First 
              If bSaved = True And .Saved = False Then .Save 
          End With 
      End Sub

      With this code, you’re automatically taken back to the last insertion point whe the document opens. If you want to get back to the start of the document, that’s just a Ctrl-Home away.

      FWIW, you could combine, say, the Document_Open macro from the first listing with the Document_Close macro from the second listing, or vice-versa, if you want to have the corresponding options only when opening or closing the document.

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

      • #1306752

        Bravo Paul. A real MVP solution.

        I don’t know enough about VBA to answer this, but does setting an invisible _DocClose bookmark automatically delete an existing bookmark with the same name? If it doesn’t, the document will get an additional bookmark each time I close it, interfering with functionality.

        Thanks.

        Ken Shaw (krsmav)

        • #1306785

          You know, I’ve got Word 2007 and Shift+F5 takes me to my previous edit. I have SP2 installed. Might that make a difference?

          I put the Previous Edit command on my QAT, but the keystroke works.

          It also works for me in Word 2010. Just my two cents…

          Kim

          • #1306819

            Shift-F5 also works for me in Word 2010 so I’m not yet convinced of the need for the macro setting the bookmark.

            However, I do see value in the principle of returning to where the cursor was when I closed the document. IMHO this is more useful than going back to the last edit anyway.

        • #1306817

          Ken
          You can’t have the same bookmark name in two locations so this won’t be a problem. Creating a new bookmark with the same name as a previous one automatically removes the previous one.

    • #1306858

      Fornerly, at least as recently as when I wrote the macro, Shift-F5 worked while the document remained open, but not after closing & reopening. Maybe MS has fixed something.

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

      • #1307159

        Fornerly, at least as recently as when I wrote the macro, Shift-F5 worked while the document remained open, but not after closing & reopening. Maybe MS has fixed something.

        Funny story: When I went to the 2009 MVP Summit, I had the Word 2010 beta on my laptop. I hadn’t yet tested Shift+F5 after reopening a document. The topic came up, and I started to show one of the developers how it didn’t work. Much to my surprise, it did work — and none of the other MVPs had known about the fix, either. We asked Stuart Stuple why the fix wasn’t documented, and he said “Do we have to tell you about everything we fix?” Well, yes… it would be nice. :rolleyes:

        • #1307762

          Paul,

          I’m a neophyte at editing the Normal template. When you say to put the script in the Normal template, how, exactly is that accomplished?

    • #1306911

      Well, I haven’t tested in 2007, but in 2010, it worked for me after closing and reopening. MS must have fixed it.

      K

    • #1306957

      Time to upgrade to 2010, I guess. Does anyone know when the next version is coming out? I’d rather not upgrade twice in quick succession. If only Home & Student included Outlook.

      • #1307126

        Info on the internet points to Office 15 due out at the end of 2012. There’s some interesting chatter — search “next version of Office” and see what you get.

        Also, I’ve since tested 2007 for Previous Edit after closing and reopening and it did not work. So it look like it’s something that was fixed with 2010.

        K

        • #1307135

          Great. Many thanks. It’s really annoying not to have the feature, so I’ll upgrade.

    • #1308101

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

    Viewing 5 reply threads
    Reply To: How to go to last edit in Word .docx docs

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

    Your information: