Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    London, Gtr London, England
    Posts
    100
    Thanks
    1
    Thanked 0 Times in 0 Posts

    backup macros (Word 2000)

    Does anyone know of a macro that keeps a sequence of earlier backups of a document? I just used a letter sent yesterday as a template for a letter sent today. I know I should have renamed from the get-go, but didn't, then saved the new doc under the name of the old doc. It would be great to have more backup of earlier versions with backup1 becoming backup2 and so forth on passage of time.

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: backup macros (Word 2000)

    It's tricky to rename files that Word thinks you have open. It's easier to change File>Save to increment a number or letter in the file name. So, for example:

    Start with Document1
    Save As My Memo.doc
    Save -> macro does Save As My Memo 001.doc
    Save ->macro does Save As My Memo 002.doc

    and so forth. Does that appeal to you?

  4. #3
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    London, Gtr London, England
    Posts
    100
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: backup macros (Word 2000)

    That would be dandy! Have you such a macro?

    Will

  5. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: backup macros (Word 2000)

    I didn't before, but... you could try this:

    <pre>Option Explicit
    Sub FileSave()
    'Save always as a new file, incrementing counter file name
    If ActiveDocument.Path = vbNullString Then 'brand new doc, show Save As dlg
    Dialogs(wdDialogFileSaveAs).Show
    Else 'increment counter and then Save As for the user
    Dim strBaseName As String, intOldNumber As Integer
    strBaseName = Left(ActiveDocument.Name, _
    InStrRev(ActiveDocument.Name, ".") - 1)
    If Val(Right(strBaseName, 3)) = 0 Then 'add a new number (001)
    ActiveDocument.SaveAs ActiveDocument.Path & "" & _
    strBaseName & " 001" & Mid(ActiveDocument.Name, _
    InStrRev(ActiveDocument.Name, "."))
    Else 'increment the existing number
    intOldNumber = CInt(Right(strBaseName, 3))
    strBaseName = Left(strBaseName, Len(strBaseName) - 3) & _
    Right("00" & CStr(intOldNumber + 1), 3)
    ActiveDocument.SaveAs ActiveDocument.Path & "" & _
    strBaseName & Mid(ActiveDocument.Name, _
    InStrRev(ActiveDocument.Name, "."))
    End If
    End If
    End Sub</pre>

    Hope this helps. Of course, at 999, bad things happen. Also, if you open an intermediate "version" and save, it will silently wipe out the next-numbered file. There are many possible ways around this, but that level of complexity is beyond a lunch hour quickie.

  6. #5
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    Quakers Hill, NSW, Australia
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: backup macros (Word 2000)

    Hi Jefferson,

    My brother-in-law is writing his life story & has just acquired a PC (= very novice) so that he can make it easier. He made it to page 138 and somehow deleted all the text and thought there may have been a problem so saved the file. (Now has 1 blank page for his efforts). Was reluctant to back-up (didn't want all these excess files on his new PC!!) so has called on me for HELP.

    I have located your backup macro and it is exactly what he needs, I've copied & saved as a macro. I'm attempting to put a button for it on the toolbar, but when I "Tools, Customize, Commands, Macros" & scroll to "FileSave" macro, it's not listed so can't add it.
    I've even tried dragging & dropping as Ed & Woody have sugested in their Office 2003 book.
    Can you offer any tips or sugestions on what I may be doing wrong?

    Thanks
    Neville

  7. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: backup macros (Word 2000)

    Jefferson is probably asleep now. FileSave is the name of the internal command Word uses when saving a file. If you create a macro with that name, it overrules the internal command, so it will be used automatically when saving the file, the user doesn't need to do anything explicitly. No custom toolbar button needed - the standard Save button and the File | Save menu item will call the macro.

    If you'd rather not overrule the built-in command, give the macro another name, for example MySave instead of FileSave. If you want to assign that to a toolbar button, make sure that the "Save in" box in the Commands tab of the Customize dialog shows the document that contains the macro, otherwise you won't see the MySave macro listed.

  8. #7
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    Quakers Hill, NSW, Australia
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: backup macros (Word 2000)

    Thanks Hans,

    Have renamed Macro added it to toolbar and it works perfect. Had to do a bit more research to find out how to edit the button name & found another helpful guide from Jefferson on adding 2 printer buttons from 2002 so followed instructions and problem fixed.

    It's very much appreciated for the info you guys can help us with.

    Neville

  9. #8
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: backup macros (Word 2000)

    I hate when that happens. For future reference, the most common cause of losing a whole document while editing is selecting all and typing something which replaces the selection. Other than learning not to do that, one can turn off typing replaces selection under Tools>Options...>Edit. Then one must press Delete or Backspace to delete the selection. If he's not in a hurry, it might be a useful "safety precaution" while he learns Word.

  10. #9
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: backup macros (Word 2000)

    But see <!post=this thread,388074>this thread<!/post>: At least with Word 2002 (SP-2), if you elect "typing replaces selection" and then try to insert any of the built-in AutoText entries that includes a date (e.g., Author, Page #, Date in the Header/Footer category), Word freezes.

  11. #10
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    London, Gtr London, England
    Posts
    100
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: backup macros (Word 2000)

    Hi Jefferson,

    I never did you an acknowledgement. So sorry. I use this macro a few times each month It is Alt-S, by my chosen keyboard command. When I create, or revise a precedent document, I make a few backups right away with this macro. Just wanted to say.

    Regards
    Will

  12. #11
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    London, Gtr London, England
    Posts
    100
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: backup macros (Word 2000)

    Is possible to add a line to Jefferson's macro, so that the macro runs every X minutes on any file in the active window?

    Regards
    Will

  13. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: backup macros (Word 2000)

    I don't think that would be a good idea. If every open document is saved under a new name every (say) 5 minutes, you'd end up with enormous amounts of numbered documents.

  14. #13
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    London, Gtr London, England
    Posts
    100
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: backup macros (Word 2000)

    Hi, Hans

    Well, yes, 12 copies an hour! But I'd only want the doc in the active window to be saved and, I suppose, if I was not working on it, I could close it.

    I create 10-20 new docs a day. Once a month, I lose a document. Sure, it may be bad management by me, but all the same, I'd not mind creating 5X the number of docs, each month, in return for
    a. Not losing a document that (inevitably) was required on a tight deadline and, as a bonus
    b. Having previous iterations of the doc to refer back to if, as I am drafting, I head off on one line of thinking which, 10 minutes later, I wish I'd not bothered with. If the version from 10 minutes ago was there, too, I'd like that.

    There shouldn't really be a disk space issue, right?

    Regards
    Will

  15. #14
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: backup macros (Word 2000)

    The Word 2003 help file has this example for scheduling a macro to run in the future, using the OnTime method:
    <hr>This example runs the macro named "Macro1" 15 seconds from the time the example is run. The macro name includes the project and module name.

    <code>Application.OnTime When:=Now + TimeValue("00:00:15"), _
    Name:="Project1.Module1.Macro1"</code><hr>
    I don't know whether it's a good idea to add this to the FileSave macro -- your work may be interrupted if Word is saving the document on a schedule without regard to whether you are busy typing or whatever.

  16. #15
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: backup macros (Word 2000)

    I still think it's a bad idea - see also JScher2000's reply.

    If you want to do this, you could use code like this in a module in your Normal.dot:

    Sub AutoExec() ' this name is obligatory
    Application.OnTime Now + TimeSerial(0, 5, 0), "SaveNewVersion"
    End Sub

    Sub SaveNewVersion()
    Dim doc As Document
    Dim strBaseName As String
    Dim intOldNumber As Integer
    Dim intPos As Integer
    On Error GoTo ErrHandler
    For Each doc In Documents
    If doc.Saved = False Then
    If doc.Path = vbNullString Then ' brand new doc, show Save As dlg
    Dialogs(wdDialogFileSaveAs).Show
    Else 'increment counter and then Save As for the user
    intPos = InStrRev(doc.Name, ".")
    strBaseName = Left(doc.Name, intPos - 1)
    If Val(Right(strBaseName, 3)) = 0 Then ' add a new number (001)
    strBaseName = strBaseName & " 001"
    Else ' increment the existing number
    intOldNumber = CInt(Right(strBaseName, 3))
    strBaseName = Left(strBaseName, Len(strBaseName) - 3) & _
    Right("00" & CStr(intOldNumber + 1), 3)
    End If
    doc.SaveAs doc.Path & "" & strBaseName & Mid(doc.Name, intPos)
    End If
    End If
    Next doc
    ExitHandler:
    Application.OnTime Now + TimeSerial(0, 5, 0), "SaveNewVersion"
    Exit Sub
    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Sub

    You may want to test it on some non-essential documents before you decide that it is too irritating to use for real. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

Page 1 of 2 12 LastLast

Posting Permissions

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