Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    2 Star Lounger
    Join Date
    Nov 2006
    Posts
    102
    Thanks
    12
    Thanked 2 Times in 2 Posts

    How to go to last edit in Word .docx docs

    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.

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    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.php?t=37085
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    Quote Originally Posted by macropod View Post
    However, I've written some macros that achieve much the same thing. See: http://www.vbaexpress.com/forum/showthread.php?t=37085
    When I click on this link I get locked out for not being registered for those forums.
    Charles Kyle Kenyon
    Madison, Wisconsin

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    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
    [MS MVP - Word]

  5. The Following User Says Thank You to macropod For This Useful Post:

    RetiredGeek (2011-11-15)

  6. #5
    2 Star Lounger
    Join Date
    Nov 2006
    Posts
    102
    Thanks
    12
    Thanked 2 Times in 2 Posts

    Thanks; One More Query

    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)

  7. #6
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts
    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

  8. #7
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    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.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  9. #8
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    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.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  10. #9
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    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
    [MS MVP - Word]

  11. #10
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts
    Well, I haven't tested in 2007, but in 2010, it worked for me after closing and reopening. MS must have fixed it.

    K

  12. #11
    2 Star Lounger
    Join Date
    Nov 2006
    Posts
    102
    Thanks
    12
    Thanked 2 Times in 2 Posts
    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.

  13. #12
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts
    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

  14. #13
    2 Star Lounger
    Join Date
    Nov 2006
    Posts
    102
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Great. Many thanks. It's really annoying not to have the feature, so I'll upgrade.

  15. #14
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    Willow Grove, Pennsylvania, USA
    Posts
    205
    Thanks
    4
    Thanked 49 Times in 40 Posts
    Quote Originally Posted by macropod View Post
    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.

  16. #15
    New Lounger
    Join Date
    Dec 2009
    Location
    VA, USA
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    Al Mongeon

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •