Macro to Set Word Defaults
Applies to all versions of Word on PC and Mac later than Word 2008. Won't work on the web versions, they have no macros.
Many of us (those of us with jobs!) frequently experience the problem where we sit down at a computer and things are not set up the way we need (or like!) them. This problem will only get worse: no company can afford the level of IT skill it takes to fully understand all the various settings across the Microsoft Office suite, let alone how to set them appropriately for each operating system, country, region, and job-description in the company. Trying to explain what you need to the out-sourced support contractor in Bangalore can quickly produce insanity...
The simplest way to handle this is to carry a copy of your Normal.dotm template with you on a USB stick, and copy it in to whichever computer you happen to use today. And that's what many of us do. But it's not a complete solution, for two reasons: often, the working copy of Normal.dotm on the computer is out of your reach due to security considerations (or ignorance...) and Normal.dotm does not contain all of the settings you need.
The macros presented here offer a solution. Hit Alt + F11 (Option + F11 on the Mac), paste the code below, Save, Close, and re-start Word. Simples :-)
Not a "perfect" solution mind you: there are some settings missing, such as spelling language and document defaults. We're working on those and we will update this article when we find a robust solution.
Your two authors do this stuff for a living: John McGhie is a consultant technical writer who has led a nomadic existance since 1986, going from company to company and project to project. Rich Michaels owns a software development company producing learning solutions for PC and Mac. John is older and grumpier than Rich, but not by much!
Difficulty Level: Medium
OK, just a word to the wise: you are about to start playing with computer code. That's like editing an important document close to deadline: you need a clear idea of what you are about to do, and you need to work slowly, carefully, and very very accurately. If you don't, you WILL break your computer, and potentially have to call the nice lady in Bangalore who can't speak English very well...
So please read this slowly and carefully before attempting it. We will very carefully talk you through it: but if you are the kind of person for whom "computers are someone else's problem, if they don't work I call support!" then you really should ask IT Support to help you with this :-)
What We Are Doing
We are about to paste some macros into the Normal.dotm master template.
The macros will almost instantly check every setting in Word, and put any right that are different to what you want.
These macros will run automatically whenever Word starts up, whenever it creates a new document, or whenever it opens a document (they must be stored in the Normal.dotm for this to work reliably).
Some Assembly Required, Batteries Not Included
Before you can use this code, you need to customise parts of it for your own use. For example: you need to customise your user name, your initials, and your address. The parts you need to customise are highlighted.
We are currently writing another article to tell you what each of the settings actually do, so you can decide which ones you need.
You also need to understand some simple things about this code, it has features that are actually quite rare in most VBA:
- This code is designed for use on both PC and Mac. The Mac version of Word is gradually getting closer and closer to the PC version, but there are still some differences. Whenever you see #If Mac Then in the code, that's a compiler directive telling the VBA compiler to compile the code differently to run on a Mac or PC.
- You will see that nearly every line is an IF statement. The reason for this is to avoid making any change if no change is needed. A user's typical Normal.dotm is a large and complex file: the less often we re-save it, the longer it will last before something fails.
- Of course, you ARE going to keep a backup of it safely tucked away, aren't you?
The Non-Breaking Spaces Bug
- You need to deal with the "non-breaking spaces" bug. The easiest way is to click this link to the .BAS file.
- The problem is that in HTML, if there is more than one space in a row, the browser converts these to non-breaking spaces (ANSI code 255 instead of ANSI code 32). Sadly, most of the Word Visual Basic Editors are not smart enough to convert them back again. This was fixed in PC Word 2016.
- One way to handle it is to paste the HTML into a Word document, then use Find/Replace to find all spaces and replace them with spaces. The Find will match both 32 and 255, the replace will replace only with 32. Then select all the code and paste it into the Visual Basic Editor: problem solved!
Importing the Code
In all versions of Word except Mac Word 2016, you can simply open the Visual Basic Editor (Alt + F11 or Option + F11) and from its File menu, choose "Import" then select the file you downloaded. If you get an error, chances are the module "AutoMacros" already exists in your Normal.dotm. Change its name and try again.
For Mac Word 2016 Only
Mac Word 2016 does not have an Import command, so do the following:
- Open the Visual Basic Editor (Option + F11).
- In the Left column (the Project Explorer Window) right-click the name that reads "Normal (Normal.dotm)"
- Choose Insert>Module
- A new blank module will appear at the bottom of the list, named "Module1". Overwrite the name with something convenient such as "AutoMacros" (no spaces).
- Open the .bas file in a text editor (TextEdit is fine...)
- Copy all the content and paste it into the right-hand window (which should be blank).
- Remove the line at the top that reads "Attribute VB_Name = "AutoMacros""
Compile the Code
Once you have the code in there, you need to check that all has transferred properly.
First, scroll the code and look for any lines that have turned entirely red. That indicates a syntax error in the line. Don't get confused: Visual Studio marks user variables in red; but a compile error turns the whole line red.
- Usually, it's the non-breaking spaces issue mentioned above. You could deal with it by simply deleting the spaces at the beginning of the line, using tabs instead. But if you have one of these you will probably have hundreds: so see above under "the non-breaking spaces bug".
- If it's not non-breaking spaces, it is likely to be broken lines. In the code we have supplied, there are no line breaks: each statement has been written on a single line. However, when transferring via a text editor, it is possible that the text editor has inserted some line breaks that should not be there. You will see this easily because both lines will have gone entirely red. All you need to do is place your cursor at the end of the top line and forward-delete until the two lines join up. They will then go the correct colour to show you the compiler has accepted the line.
The proper way to check the code is to go to the Debug menu is the Visual Basic Editor and choose "Compile Normal". The first error found in the code will be highlighted and an error dialog will appear which will tell you what is wrong.
In Word Mac 2016, sadly there is no Debug menu. The best you can do is to click in the line that reads Sub SetToolsOptions() then attempt to run the code. Before Word can run the code it must first compile it, and any errors will produce the same result.
Either way, if there are any errors, you need to resolve them. Keep fixing until there are no errors, because the code won't work at all until it's clean.
The Code
The following is just a "picture" of the code to show you what it should look like when it is all compiled. You could copy from here, but it is much easier to click this link to download the .bas file.
Sub AutoExec()
Application.OnTime When:=Now + TimeValue("00:00:03"), Name:="SetToolsOptions"
End Sub
Sub AutoOpen()
Application.OnTime When:=Now + TimeValue("00:00:02"), Name:="SetToolsOptions"
End Sub
Sub AutoNew()
Application.OnTime When:=Now + TimeValue("00:00:02"), Name:="SetToolsOptions"
End Sub
Sub SetToolsOptions()
'
' Corrects Word Defaults
' Macro written January 2016 by Rich Michaels and John McGhie
'
If Application.Documents.Count > 0 Then
With Application
'for all PC versions and Mac 2011 & 2016
If .DisplayRecentFiles <> True Then .DisplayRecentFiles = True
If .UserName <> "John McGhie" Then .UserName = "John McGhie"
If .UserInitials <> "JGM" Then .UserInitials = "JGM"
If .UserAddress <> "" Then .UserAddress = ""
#If Mac Then
'for only Mac 2011 and 2016
If .DefaultSaveFormat <> "WordDocument" Then .DefaultSaveFormat = "WordDocument"
#Else
'for all PC versions
If .DefaultSaveFormat <> "" Then .DefaultSaveFormat = ""
#End If
#If MAC_OFFICE_VERSION >= 15 Then
'do nothing for Mac 2016
#Else
'for all PC versions and Mac 2011 only
If .DisplayStatusBar <> True Then .DisplayStatusBar = True
#End If
#If Mac Then
'do nothing for either Mac 2011 or 2016
#Else
'for all PC versions only
If .ShowWindowsInTaskbar <> True Then .ShowWindowsInTaskbar = True
If .ShowStartupDialog <> False Then .ShowStartupDialog = False
#End If
End With
With ActiveWindow
#If Mac Then
'do nothing with Mac 2011 and 2016
#Else
'for all PC versions only
If .DisplayLeftScrollBar <> False Then .DisplayLeftScrollBar = False
If .DisplayRightRuler <> False Then .DisplayRightRuler = False
#End If
'for all PC versions and Mac 2011 & 2016
If .DisplayHorizontalScrollBar <> True Then .DisplayHorizontalScrollBar = True
If .DisplayVerticalScrollBar <> True Then .DisplayVerticalScrollBar = True
If .StyleAreaWidth <> 0 Then .StyleAreaWidth = 0
If .DisplayVerticalRuler <> True Then .DisplayVerticalRuler = True
If .DisplayScreenTips <> True Then .DisplayScreenTips = True
With .View
If .Draft <> False Then .Draft = False
If .WrapToWindow <> True Then .WrapToWindow = True
If .ShowPicturePlaceHolders <> False Then .ShowPicturePlaceHolders = False
If .ShowFieldCodes <> False Then .ShowFieldCodes = False
If .ShowBookmarks <> False Then .ShowBookmarks = False
If .FieldShading <> Word.WdFieldShading.wdFieldShadingAlways Then
.FieldShading = Word.WdFieldShading.wdFieldShadingAlways
End If
If .ShowTabs <> False Then .ShowTabs = False
If .ShowSpaces <> False Then .ShowSpaces = False
If .ShowParagraphs <> False Then .ShowParagraphs = False
If .ShowHyphens <> False Then .ShowHyphens = False
If .ShowHiddenText <> False Then .ShowHiddenText = False
If .ShowAll <> True Then .ShowAll = True
If .ShowDrawings <> True Then .ShowDrawings = True
If .ShowObjectAnchors <> False Then .ShowObjectAnchors = False
If .ShowTextBoundaries <> True Then .ShowTextBoundaries = True
If .ShowHighlight <> True Then .ShowHighlight = True
If .RevisionsMode <> Word.WdRevisionsMode.wdBalloonRevisions Then
.RevisionsMode = Word.WdRevisionsMode.wdBalloonRevisions
End If
If .RevisionsBalloonShowConnectingLines <> True Then
.RevisionsBalloonShowConnectingLines = True
End If
If .RevisionsBalloonSide <> Word.WdRevisionsBalloonMargin.wdRightMargin Then
.RevisionsBalloonSide = Word.WdRevisionsBalloonMargin.wdRightMargin
End If
If .RevisionsBalloonWidthType <> Word.WdRevisionsBalloonWidthType.wdBalloonWidthPoints Then
.RevisionsBalloonWidthType = Word.WdRevisionsBalloonWidthType.wdBalloonWidthPoints
End If
If .RevisionsBalloonWidth <> 156 Then .RevisionsBalloonWidth = 156
#If Mac Then
#If MAC_OFFICE_VERSION >= 15 Then
'for Mac 2016 only
If .DisplayPageBoundaries <> True Then .DisplayPageBoundaries = True
#Else
'do nothing with Mac 2011
#End If
#Else
'for all PC versions only
If .ShowAnimation <> True Then .ShowAnimation = True
If .DisplaySmartTags <> True Then .DisplaySmartTags = True
#End If
End With
End With
'for all PC versions and Mac 2011 & 2016
With Application.Options
If .Pagination <> True Then .Pagination = True
If .WPHelp <> False Then .WPHelp = False
If .WPDocNavKeys <> False Then .WPDocNavKeys = False
If .ShortMenuNames <> False Then .ShortMenuNames = False
If .RTFInClipboard <> True Then .RTFInClipboard = True
If .BlueScreen <> False Then .BlueScreen = False
If .EnableSound <> False Then .EnableSound = False
If .ConfirmConversions <> False Then .ConfirmConversions = False
If .UpdateLinksAtOpen <> True Then .UpdateLinksAtOpen = True
If .SendMailAttach <> True Then .SendMailAttach = True
If .MeasurementUnit <> Word.WdMeasurementUnits.wdCentimeters Then
.MeasurementUnit = Word.WdMeasurementUnits.wdCentimeters
End If
If .AnimateScreenMovements <> True Then .AnimateScreenMovements = True
If .VirusProtection <> False Then .VirusProtection = False
If .ApplyFarEastFontsToAscii <> False Then .ApplyFarEastFontsToAscii = False
If .ReplaceSelection <> True Then .ReplaceSelection = True
If .AllowDragAndDrop <> True Then .AllowDragAndDrop = True
If .AutoWordSelection <> True Then .AutoWordSelection = True
If .INSKeyForPaste <> False Then .INSKeyForPaste = False
If .PasteSmartCutPaste <> True Then .PasteSmartCutPaste = True
If .AllowAccentedUppercase <> False Then .AllowAccentedUppercase = False
If .TabIndentKey <> True Then .TabIndentKey = True
If .Overtype <> False Then .Overtype = False
If .AllowClickAndTypeMouse <> False Then .AllowClickAndTypeMouse = False
If .PictureWrapType <> Word.WdWrapTypeMerged.wdWrapMergeInline Then
.PictureWrapType = Word.WdWrapTypeMerged.wdWrapMergeInline
End If
If .DisplayPasteOptions <> True Then .DisplayPasteOptions = True
If .FormatScanning <> False Then .FormatScanning = False
If .SmartParaSelection <> True Then .SmartParaSelection = True
If .UpdateFieldsAtPrint <> True Then .UpdateFieldsAtPrint = True
If .UpdateLinksAtPrint <> True Then .UpdateLinksAtPrint = True
If .PrintBackground <> True Then .PrintBackground = True
If .PrintProperties <> False Then .PrintProperties = False
If .PrintFieldCodes <> False Then .PrintFieldCodes = False
If .PrintComments <> False Then .PrintComments = False
If .PrintHiddenText <> False Then .PrintHiddenText = False
If .PrintDrawingObjects <> True Then .PrintDrawingObjects = True
If .PrintDraft <> False Then .PrintDraft = False
If .PrintReverse <> False Then .PrintReverse = False
If .MapPaperSize <> False Then .MapPaperSize = False
If .PrintOddPagesInAscendingOrder <> False Then .PrintOddPagesInAscendingOrder = False
If .PrintEvenPagesInAscendingOrder <> False Then .PrintEvenPagesInAscendingOrder = False
If .BackgroundSave <> True Then .BackgroundSave = True
If .CreateBackup <> True Then .CreateBackup = True
If .SavePropertiesPrompt <> False Then .SavePropertiesPrompt = False
If .SaveInterval <> 10 Then .SaveInterval = 10
If .SaveNormalPrompt <> False Then .SaveNormalPrompt = False
If .WarnBeforeSavingPrintingSendingMarkup <> False Then .WarnBeforeSavingPrintingSendingMarkup = False
If .CheckSpellingAsYouType <> True Then .CheckSpellingAsYouType = True
If .CheckGrammarAsYouType <> True Then .CheckGrammarAsYouType = True
If .SuggestSpellingCorrections <> True Then .SuggestSpellingCorrections = True
If .SuggestFromMainDictionaryOnly <> False Then .SuggestFromMainDictionaryOnly = False
If .CheckGrammarWithSpelling <> True Then .CheckGrammarWithSpelling = True
If .ShowReadabilityStatistics <> False Then .ShowReadabilityStatistics = False
If .IgnoreUppercase <> True Then .IgnoreUppercase = True
If .IgnoreMixedDigits <> True Then .IgnoreMixedDigits = True
If .IgnoreInternetAndFileAddresses <> True Then .IgnoreInternetAndFileAddresses = True
If .AllowCombinedAuxiliaryForms <> True Then .AllowCombinedAuxiliaryForms = True
If .EnableMisusedWordsDictionary <> True Then .EnableMisusedWordsDictionary = True
If .UseGermanSpellingReform <> True Then .UseGermanSpellingReform = True
If .InsertedTextMark <> Word.WdInsertedTextMark.wdInsertedTextMarkUnderline Then
.InsertedTextMark = Word.WdInsertedTextMark.wdInsertedTextMarkUnderline
End If
If .InsertedTextColor <> Word.WdColorIndex.wdByAuthor Then .InsertedTextColor = Word.WdColorIndex.wdByAuthor
If .DeletedTextMark <> Word.WdDeletedTextMark.wdDeletedTextMarkStrikeThrough Then
.DeletedTextMark = Word.WdDeletedTextMark.wdDeletedTextMarkStrikeThrough
End If
If .DeletedTextColor <> Word.WdColorIndex.wdByAuthor Then .DeletedTextColor = Word.WdColorIndex.wdByAuthor
If .RevisedPropertiesMark <> Word.WdRevisedPropertiesMark.wdRevisedPropertiesMarkNone Then
.RevisedPropertiesMark = Word.WdRevisedPropertiesMark.wdRevisedPropertiesMarkNone
End If
If .RevisedPropertiesColor <> Word.WdColorIndex.wdByAuthor Then .RevisedPropertiesColor = Word.WdColorIndex.wdByAuthor
If .RevisedLinesMark <> Word.WdRevisedLinesMark.wdRevisedLinesMarkOutsideBorder Then
.RevisedLinesMark = Word.WdRevisedLinesMark.wdRevisedLinesMarkOutsideBorder
End If
If .RevisedLinesColor <> Word.WdColorIndex.wdAuto Then .RevisedLinesColor = Word.WdColorIndex.wdAuto
If .CommentsColor <> Word.WdColorIndex.wdByAuthor Then .CommentsColor = Word.WdColorIndex.wdByAuthor
#If Mac Then
'do nothing with Mac 2011 and 2016
#Else
'for all PC versions only
If .AllowPixelUnits <> False Then .AllowPixelUnits = False
If .AllowReadingMode <> False Then .AllowReadingMode = False
If .InterpretHighAnsi <> Word.WdHighAnsiText.wdHighAnsiIsHighAnsi Then
.InterpretHighAnsi = Word.WdHighAnsiText.wdHighAnsiIsHighAnsi
End If
If .BackgroundOpen <> False Then .BackgroundOpen = False
If .AutoCreateNewDrawings <> False Then .AutoCreateNewDrawings = False
If .CtrlClickHyperlinkToOpen <> True Then .CtrlClickHyperlinkToOpen = True
If .AutoKeyboardSwitching <> False Then .AutoKeyboardSwitching = False
If .PromptUpdateStyle <> False Then .PromptUpdateStyle = False
If .ShowFormatError <> False Then .ShowFormatError = False
If .SmartCursoring <> True Then .SmartCursoring = True
If .PrintXMLTag <> False Then .PrintXMLTag = False
If .PrintBackgrounds <> False Then .PrintBackgrounds = False
If .LocalNetworkFile <> False Then .LocalNetworkFile = False
If .AllowFastSave <> False Then .AllowFastSave = False
If .DisableFeaturesbyDefault <> False Then .DisableFeaturesbyDefault = False
If .StoreRSIDOnSave <> True Then .StoreRSIDOnSave = True
If .ShowMarkupOpenSave <> True Then .ShowMarkupOpenSave = True
If .AllowCompoundNounProcessing <> True Then .AllowCompoundNounProcessing = True
If .RevisionsBalloonPrintOrientation <> Word.WdRevisionsBalloonPrintOrientation.wdBalloonPrintOrientationPreserve Then
.RevisionsBalloonPrintOrientation = Word.WdRevisionsBalloonPrintOrientation.wdBalloonPrintOrientationPreserve
End If
#End If
End With
'for all PC versions and Mac 2011 & 2016
With Application.ActiveDocument
If .PrintPostScriptOverText <> False Then .PrintPostScriptOverText = False
If .PrintFormsData <> False Then .PrintFormsData = False
If .ReadOnlyRecommended <> False Then .ReadOnlyRecommended = False
If .EmbedTrueTypeFonts <> False Then .EmbedTrueTypeFonts = False
If .SaveFormsData <> False Then .SaveFormsData = False
If .SaveSubsetFonts <> False Then .SaveSubsetFonts = False
If .ReadOnlyRecommended <> False Then .ReadOnlyRecommended = False
If .RemovePersonalInformation <> False Then .RemovePersonalInformation = False
If .RemoveDateAndTime <> False Then .RemoveDateAndTime = False
If .ShowGrammaticalErrors <> True Then .ShowGrammaticalErrors = True
If .ShowSpellingErrors <> True Then .ShowSpellingErrors = True
#If Mac Then
'do nothing with Mac 2011 and 2016
#Else
'for all PC versions only
If .DoNotEmbedSystemFonts <> True Then .DoNotEmbedSystemFonts = True
If .DisableFeatures <> False Then .DisableFeatures = False
If .EmbedSmartTags <> False Then .EmbedSmartTags = False
If .SmartTagsAsXMLProps <> False Then .SmartTagsAsXMLProps = False
If .EmbedLinguisticData <> False Then .EmbedLinguisticData = False
#End If
End With
End if
End Sub