Save Documents with Revision Numbers in Word

This is a macro for Microsoft Word to save documents with incremented revision numbers in order to prevent loss of work and to easily revert changes.

  • When saving this will save the document with the original filename.
  • Everytime it is saved using this macro it will append the revision number to the filename.
    • For Example: Dissertation – Revision 011 – Jan 6 2011.doc

Installation instructions for Microsoft Word 2010:

  1. Make sure the Developer Tab is enabled:
    • Office 2010:
      1. Click File -> Options
      2. Click Customize Ribbon on the left.
      3. In the right column, check the ‘Developer’ check box.
      4. Click OK.
    • Office 2007:
      1. Click the Office button in the top left.
      2. Click “Word Options” located in the bottom right of the menu.
      3. On the left, click Popular.
      4. In the right column, click “Show Developer tab in the Ribbon”.
      5. Click OK.
  2. Click the Developer tab in Word.
  3. Click Macros.
  4. In the Macro name field type “SaveMacro” and click the Create button.
  5. Delete everything from Sub SaveMacro() to End Sub.
  6. Copy and paste all the text in the box below:Sub SaveMacro()
    Dim WSHShell, RegKey, rkeyWord, Result
    Set WSHShell = CreateObject("WScript.Shell")
    Dim intCount As Integer
    Dim strDate As String
    Dim strPath As String
    Dim strFile As String
    Dim strFileType As WdDocumentType
    Dim strRevisionName As String
    Dim intPos As Integer
    Dim sExt As String
    strDate = Format((Date), "dd mm yyyy")
    sExt = ".doc"
    strFileType = wdFormatDocument
    With ActiveDocument
    On Error GoTo CancelledByUser
    If Len(.Path) = 0 Then
    .Save
    End If
    strPath = .Path
    strFile = .Name
    End With
    intPos = InStr(strFile, " - ")
    If intPos = 0 Then
    intPos = InStrRev(strFile, ".doc")
    End If
    strFile = Left(strFile, intPos - 1)
    Start:
    RegKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\Word\Settings\"
    On Error Resume Next
    rkeyWord = WSHShell.RegRead(RegKey & strFile)
    If rkeyWord = "" Then
    WSHShell.regwrite RegKey & strFile, 0
    GoTo Start:
    End If
    intCount = Val(rkeyWord) + 1
    WSHShell.regwrite RegKey & strFile, intCount
    strRevisionName = strPath & "\" & strFile & " - Revision " & Format(intCount, "00#") & " - " & strDate & sExt
    ActiveDocument.SaveAs strRevisionName
    Exit Sub
    CancelledByUser:
    MsgBox "Cancelled By User", , "Save Cancelled."
    End Sub
  7. Now click on the down arrow from the Quick Access Toolbar, then click More Commands…
  8. Now under where it says “Choose commands from:” change the drop down box to Macros.
  9. Click on Normal.NewMacros.SaveMacro then click Add.
  10. It will now appear in the right column.
  11. If you want to change the icon, click on the Macro, then click Modify below.
  12. Once done, click OK.

6 comments

  1. I get a syntax error at the start date line with Carl Norton’s scripted macro. I am a neophyte with this stuff and don’t know the problem. I can see three MMM for month and thought that by changing that to two MM it would correct the syntax error, but no such luck. I am using MS Office Home and Student 2010 – Word version 14.0.6112.5000 32 bit.

    This syntax error dialog box occurs when I click Macros on the Developr tab, select SaveMacro and then Run. However, if I am in Word and prior to saving the doc, I click on the icon for this macro that I created in the QuickAccess Toolbar, I then get the following message: Compile Error: Syntax Error, and the following is highlighted: strDate = Format((Date), “dd MM yyyy”).

    1. Hi Pali,

      It seems that the code did not copy correctly into the article. I’ve fixed this as well as making a few changes.

  2. With this addition it works for normal Ctrl + S (If somebody lazy or forgetful to click on the ‘SaveMacro’ button)

    Sub FileSave()
    SaveMacro
    End Sub

  3. I have been looking for something like this for ages. I have run it and made some tweaks on the date format but it runs very well. Many, many thanks.

Leave a comment

Your email address will not be published. Required fields are marked *