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.

Popular posts from this blog

Setup cannot find office.en-us\dwtrig20.exe during office installation

Problem: 

Setup cannot find office.en-us\dwtrig20.exe during office installation

Solution:

Method 1:

a) Uninstall skype form control panel.

b) After installing office, re-install skype.

Method 2:
a) Browse disk by right clicking on it with mouse.
b) Double click on setup.exe file from the same location.

Method 3:
Note: Take backup of your registry before modifying it. 
For registry backup: open "run" >> type "regedit" >> goto "file" >> click on "export" on desktop.

a) Edit the registry.
HKEY_LOCAL_MACHINE > SOFTWARE > MICROSOFT > OFFICE Delete the keys (items) you find in the OFFICE folder but not the sub-folders. This removes traces of previous installs to avoid possible conflicts when installing the new version of Office.

b)HKEY_LOCAL_MACHINE > SOFTWARE > MICROSOFT > OFFICE > DELIVERY > SOURCEENGINE > DOWNLOADS
Delete the keys (items) you find here.

How to add Startup items to Windows 8.

Problem

You want to be able to add startup items that run when Windows starts. In previous versions of Windows, you could easily add them to the “Startup” folder in the Start menu which is no longer visible.

Solution

Open the Windows 8 start screen by doing one of the following:
Press the Windows key
Move mouse to the bottom left of the screen. When the start screen icon appears, click once.

OR (as commented by Rick) Press the ‘Windows key’+'R’
Type %appdata% and press Enter. This should take you to “C:\Users\<User-Name>\AppData\Roaming”.
Navigate to “\Microsoft\Windows\Start Menu\Programs\Startup”. The full path should now look something like:
“C:\Users\<user-name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup”.
Add shortcuts to the programs you want to automatically start into this folder.

You can now add any shortcuts you want to start when you start your computer.

Excel 2013 right click doesn't work in spreadsheet.

Problem:

Excel 2013 right click doesn't work in spreadsheet.

Solution:

Check if excel works in safe mode.
1. Hold Windows key + R.
2. Copy and paste, or type the following command in the Open box, and then press Enter:
Excel /safe

Note: There is space between Excel and / If Excel safe works, disable the add-ins following steps mentioned below and determine the problem causing add-in: 
Try deleting following key from registry.
Excel 2007. Go to regedit and delete Options entry from HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\ and verify the result.
Note:
• Hold Windows key + R.
• Copy and paste, or type the following command in the Open box, and then press Enter:
regedit
HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Options
right click on Options and delete it.
Note: Ensure to back up the registry before any modification or deletion.
a) Locate and click the key or subkey that you want to back up.
b) Click the File menu, and then click Export.
c) In the Save in box, select the locati…