When you open an Word document from an email and start making changes to it, it’s easy to forget that you’re only editing a “temporary” document. If you save your changes it’s often quite difficult to find your revised document again.
To help avoid that here’s a nice snippet of VBA code which you can use to issue you a warning message every time you open a document from an email, like this:
As a kind of “bonus” the following script will also warn you if the document you are opening has tracked changes enabled, and ask if you want to turn them off.
To install the code open up Word and press Alt+F11 to get into the Microsoft Visual Basic Editor.
In the left hand pane under “Normal” double click “Microsoft Word Objects” then double click “ThisDocument”, and enter the following code in the pane on the right. It should all look something like this:
And here’s the code to put in there. Please note that you’ll need to remove the apostrophe from the beginning of the line saying ‘MsgBox(ActiveDocument.Path) and then open an document from an email in order to find out and jot down the Windows file path of your temporary folder, which you need to enter later in the code. I figure if you’ve been brave enough to go this far then this step should be plain sailing for you :)
Private Sub Document_Open() ' the following code will determine if the document you are opening ' has tracked changes enabled and ask if you want to turn them off ' it will also warn you if you are opening a document from an email ' in case you intend making changes to it Dim TurnOffTrackedChanges As Variant ' Uncomment the following line and open a Doc from an email to find out what your temporary folder is 'MsgBox(ActiveDocument.Path) If ActiveDocument.TrackRevisions = True Then TurnOffTrackedChanges = MsgBox("This document has tracked changes enabled." & vbCrLf & vbCrLf & "Do you want to turn tracked changes off?", vbYesNo, "WARNING - Tracked changes enabled!") If TurnOffTrackedChanges = vbYes Then ActiveDocument.TrackRevisions = False MsgBox ("Tracked changes have been disabled :)") End If End If ' You need to put your temporary folder name below - uncomment the message box at the top to find out what it is 'example for WinXP If ActiveDocument.Path = "D:Documents and SettingsPaulLocal SettingsApplication DataOperaOpera 11.64temporary_downloads" Then ' Example for Win7 'If ActiveDocument.Path = "C:UsersLee CliffordAppDataLocalOperaOperatemporary_downloads" Then MsgBox ("WARNING! You may have opened a temporary copy of this document from an email as the current file path is" & vbCrLf & vbCrLf & ActiveDocument.Path & vbCrLf & vbCrLf & "If you intend making any changes you should save it RIGHT NOW to a different location... or you could lose your changes!"), vbCritical End If End Sub