Skip to main content

Create auto backup for word documents using macro.

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:
Make sure the Developer Tab is enabled:
Office 2010:
Click File -> Options
Click Customize Ribbon on the left.
In the right column, check the ‘Developer’ check box.
Click OK.
Office 2007:
Click the Office button in the top left.
Click “Word Options” located in the bottom right of the menu.
On the left, click Popular.
In the right column, click “Show Developer tab in the Ribbon”.
Click OK.
Click the Developer tab in Word.
Click Macros.
In the Macro name field type “SaveMacro” and click the Create button.
Delete everything from Sub SaveMacro() to End Sub.
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


Sub FileSave()
SaveMacro
End Sub


Now click on the down arrow from the Quick Access Toolbar, then click More Commands…
Now under where it says “Choose commands from:” change the drop down box to Macros.
Click on Normal.NewMacros.SaveMacro then click Add.
It will now appear in the right column.
If you want to change the icon, click on the Macro, then click Modify below.
Once done, click OK.

Comments

Popular posts from this blog

Error code 0x8007000D when trying to activate a Windows server 2008 or Windows 7 machine using any type of product key.

Error code 0x8007000D when trying to activate a Windows server 2008 or Windows 7 machine using any type of product key. Solution: Symptoms You try to activate a Windows Server 2008 or Windows 7 machine using any type of product key. Running slsmgr -dlv or slmgr -ato from a command line generates the following: The data is invalid. Error code 8007000d. Cause The System account by default has Full Control permissions to the registry path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root and any subkeys. If those permissions have been altered for the 'Root' key or any subkey(s), we would see the error code 0x8007000D Resolution Assign the minimum permission of "Enumerate Subkeys" to the System account for the registry path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root and any of its subkeys. To assign the permissions automatically, click the Fix this problem link.  Then click Run in the File Download dialog box, and then follow the steps in the Fix it wizar...

How to change the color of the wavy underline that indicates spelling errors.?

Issue: How to change the color of the wavy underline that indicates spelling errors.? Solution: To change the color of the wavy underline that indicates spelling errors, follow these steps: 1.      Click Start , click Run , type regedit , and then click OK . 2.      Locate and then click the following registry subkey: HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools 3.      If the SpellingWavyUnderlineColor entry exists, go to step 6. If the SpellingWavyUnderlineColor entry does not exist, go to step 4. 4.      On the Edit menu, point to New , and then click DWORD Value . 5.      In the right pane, type SpellingWavyUnderlineColor . This is the name of the new entry. 6.      In the right pane, double-click SpellingWavyUnderlineColor . 7.      In the Edit DWORD Value dialog box, click Hexadecimal . 8.      In th...

How to Recover Deleted Mails in Outlook 2013

Issue: How to Recover Deleted Mails in Outlook 2013 Solution:  If you are using exchange account in outlook 2013 and have deleted the emails accidentally from your Inbox but you want them back into the Inbox. There is one inbuilt option on outlook 2013 that you can use to recover the emails. Please follow the steps below to remover the emails. 1. Click on folder tab from top of the outlook bar. 2. Look for recover deleted option under folder tab. 3. Select the emails from the dialog box you can select multiple by holding CTRL key. 4. Click on Restore button to recover the emails. I Hope this would fix the issue for you.