|
|
Automated "Boilerplate"Autotext and AutoCorrect in Microsoft Word - including Building Blocks with a little about AutoFormat as you typeby Charles Kyle Kenyon, Esq. This page last edited Sunday 01 December 2024
There are no promises that this chapter is of the same quality and depth as the other chapters of this guide. That is because it was written by a single author not working with Microsoft. You will not find this chapter on the Microsoft site. AutoText is a one form of Building Blocks in ribbon versions of Word. Virtually everything said about AutoText here applies to all Building Blocks. Comments are welcome. What You Will LearnAfter completing this lesson, you will be able to:
Additional Written (and Web) Resources
Boilerplate Macro Package (Commercial Add Ins)
When I started using computer word processing the way to repeat text was with macros (even on paper tape!). I learned to write very lengthy and complex macros in Word Perfect. Macros are still useful in Word, but repeating boilerplate text is not a good use for them. Word has AutoText and AutoCorrect that do a much better job and are more easily edited. Distinguishing Among AutoText, AutoFormat and AutoCorrect (Overview and definitions)There are three "Auto" functions that are easily confused and work in similar ways when you are creating documents. Those are AutoText, AutoFormat, and AutoCorrect. AutoFormat and the related AutoFormat as you type are not useful for preparing boilerplate and may be discussed in depth elsewhere. You can turn functions on and off but you can't customize them. They don't insert text but can change how it looks dramatically. AutoFormat is applied all at once to a document while AutoFormat as you type changes the format of your text automatically as you type it. See below for a bit more on these. Both AutoText and AutoCorrect allow the user to pick text to be inserted. Both come with predefined replacements. They are stored in different places and are edited or transferred in different ways. Both can insert and replace text but they act and show up on your screen in different ways. AutoCorrect does what it name implies - fixes errors. It can do much more, though. It checks each "word" as you type by looking that "word" up in a database of corrections. Points to keep in mind:
The advantage of AutoCorrect is that it corrects errors in real time rather than coming back for correction later. A very real disadvantage is that what Microsoft considers an error may be a word you intend to use. If you use Google to search for "AutoCorrect fun" or "AutoCorrect errors" you'll likely find some entertaining examples. In Word, the most likely source of problems is checking the box at the bottom of the option to automatically use suggestions from the Spelling Checker. (You can get the following dialog to show up using the keyboard short cut of Alt+T, A. That is, hold down the Alt key, and press T, release those and press A.)
Those suggestions will often be right, but when they are not, Word makes the substitution without telling you! AutoCorrectAutoCorrect is sometimes confused with AutoText but the two are very different. A key distinction is that unformatted AutoCorrect entries are shared by all Office programs. AutoText and Building Blocks are Word components only. (Outlook can use AutoText and Textbox building blocks but they are not shared with Word in Ribbon versions). A second distinction is that AutoText is stored in templates, while AutoCorrect is (mostly) stored in language-specific ACL files. Formatted AutoCorrect entries are stored in the normal template. See Exploiting AutoCorrect by Suzanne Barnhill, MVP for creative ideas on making the best use of AutoCorrect. With AutoCorrect, if you type the entry name and press Enter or the spacebar or punctuation, Word will insert the entry at that location, replacing what you typed. It will do this without notice to the user and very quickly. You can undo this with Ctrl+Z if you notice it and it is an unwanted replacement. For this reason:
The key to using AutoCorrect is the AutoCorrect Option settings. AutoCorrect OptionsIn Word 97-2003 you access the AutoCorrect options dialog under the Tools menu. In Word 2007-2024 you get to it from the Options. This is listed as Word Options under the Office Button in Word 2007 and under the File Tab in Word 2010-2024. In all versions of Word you can reach it with the keyboard shortcut Alt+T, A.
Word 2010 AutoCorrect Options Dialog (tabs different in earlier versions) A quick way to get to AutoCorrect Options in Word 2007-2024 is to click on the lightning bolt drop down after an AutoCorrect. This is shown to the right. Word just corrected "hte" to "The" at the beginning of a sentence. Bringing the mouse pointer over the word displays the lightning bolt and after a few seconds the tooltip. Clicking on the lightning bolt brings up the AutoCorrect Options Dialog. If this is not showing up, you need to check the box in the AutoCorrect Options dialog to show AutoCorrect Options buttons. Using AutoCorrect to Correct typosI suspect this is the original purpose behind AutoCorrect and the reason for the name. If you type "adn" and press the space bar, Word changes this to "and." When you type "adequit" followed by a period, Word changes it to "adequate" followed by the period. Like all AutoCorrect text replacements (other than the functions shown below) these are set forth in the table of AutoCorrect replacements.
Again, these are language-specific. AutoCorrect, though, can be used for much more than correcting typos. Three uses are insertion of boilerplate text quickly, automatic insertion of formatted fractions, and insertion of dummy or random text. Using AutoCorrect for quickly typing boilerplate textSay the name of your company is "International WireWorks, Inc." and you have to type that 40 times a day. You could select the name and save it (without the period at the end) as an AutoCorrect entry with the trigger being "iww." Whenever you type "iww." in your documents, you will get "International WireWorks, Inc." Note, if you had included the period in your saved text, you would have two periods in your resulting text. The same can be done with much more extensive phrases. Using AutoCorrect to type formatted fractionsAutoFormat as You Type already provides limited insertion of fractions. These are limited to the fractions built into the font being used. If you have the option for this checked, Word will replace typed common fractions like 1/2 and 1/3 with the font characters for those. (This option is checked by default in a Word installation.)
However many fractions (i.e. 2/3, 1/16) are not included in fonts. If you want to have more fractions handled automatically and have them appear with consistent formatting in your documents, you could create formatted AutoCorrect entries with the numerator formatted as superscript and the denominator formatted as subscript. To maintain consistent formatting, you would then want touncheck the "Fractions" option on the AutoFormat as You Type option and include those fractions in your formatted AutoCorrect entries.
Since these are formatted entries, they are stored in the normal template, not in the language-specific acl file. For more on this, see How Can I Create a Fraction in Word that isn't in Any of the Fonts that I Have? For a macro solution see Create a Fraction by Graham Mayor. For a file that can be used with Jay Freedman's backup utility to add many of these in your installation, see Fractions AutoCorrect Document - add more fractions to AutoCorrect. Using AutoCorrect to Insert Random Text - Rand and Lorem functionsThere is in AutoCorrect a function to insert random or filler text to help you see how a template will look when it is used. In Word 2000-2003 this is the Rand function. Later versions also have the Lorem function. Both use AutoCorrect but allow the user to specify the amount of text. Both require that they begin a paragraph and both are triggered by the Enter key at the end of the paragraph. Here are the two functions before the enter key is pressed: =rand(5) =rand(5,3) =lorem(7) =lorem(7,3) The function can take one or two parameters. When only one parameter is given, that is the number of paragraphs of three sentences. When two parameters are given, the first is the number of paragraphs and the second is the number of sentences in each paragraph. In Word 2000-2003, the text used by rand is the sentence: The quick brown fox jumps over the lazy dog. This sentence uses all 26 letters used in English but does not give the variety offered by the ribbon versions of Word. You can get this in ribbon versions of word using the function "rand.old" instead of "rand." =rand.old(5) =rand.old(5,3) In ribbon versions of Word the text used by rand appears to come from Word's help files. The lorem function works with the same parameters but produced nonsense text that looks like Latin and is adapted from text written by Cicero. See Lorem Ipsum. It looks much more like ordinary text (at least in English or Latin). Sentence length varies and there is a normal distribution of ascenders and descenders in the letters. This use as dummy text dates back to the middle ages. For more on this AutoCorrect function, see The Rand "Virus" or how to insert dummy text into a document. You can download a free Add-In for Word 2007-2024 that writes these formulae for you to help you learn them. It has a custom dialog box that gives you choices. Turning Off AutoCorrectUsually what people want to really turn off is AutoFormat as you Type. If you truly want to turn off AutoCorrect, uncheck all of the boxes on the AutoCorrect Options dialog.
File>Options>Proofing>AutoCorrect Options Note, I do not recommend turning AutoCorrect off, but do recommend turning off the option to Automatically use suggestions from the spelling checker. Using AutoFormat as you Type to insert paragraph borders (fancy lines)It's easy to add a variety of horizontal divider lines to Word documents. To create a solid, black line for example, type three HYPHENS (-) at the beginning of a new paragraph and then press ENTER. Typing three UNDERSCORES (_) will make a thicker line, and so on. (If you type more than three, it will still work.) See the table below for a guide to the types of lines you can create:
Note: These can be very disconcerting if you don't know that this is what is happening. For that reason, many experienced Word users, including your author, turn this option off. If you want to not apply these (or any other AutoFormat or AutoCorrect) press Ctrl+Z immediately after Word makes the change. You can also add a space after your three (or more) characters and Word will not convert the characters to a paragraph border. If you are past the point where Ctrl+Z will help, you can get rid of one of these borders by removing the border format from the paragraph. In Word 97-2003, place your cursor in the text line above the border and use Format => Borders and Shading. Make sure that the apply to box says "paragraph" and click on the box for "none." In Word 2007-2024 (365), place your cursor in the text line above the border and on the Home tab find the Borders and Shading dropdown in the paragraph group; it will be highlighted (shown left). Select No Border.
Using AutoFormat as you Type to insert Em-dashes and En-Dashes
Em-dashes (—) and
En-dashes (–)
are true dashes, not hyphens (-) or minus signs. An En-dash has about the width of the
upper-case letten N, and an Em-dash has about the width of the upper-case letter M.
To insert an Em-dash you put two hyphens -- without spaces between two words or characters as you type.
To insert an En-dash you need to put it between two words with a space on either side of two hypens or minus signs.
Both of these AutoFormat as you Type methods require that the second word be ended in some way (space or punctuation) before the transformation takes place. These can be inserted using Insert > Symbol. There are keyboard shortcuts for these as well. They use the minus sign on the numeric keypad.
If you do not like the spaces around the En-dash, you may want to use AutoCorrect instead. That is discussed by MVP Jay Freedman in this Microsoft Answers thread. Where Are AutoCorrect Entries Stored?Unformatted AutoCorrect entries are stored in .acl files. These files are language-specific. That is, if you change the language setting for your text, a different .acl file will be used (or generated). Formatted AutoCorrect entries are stored in normal.dot / normal.dotm. See also
What Files Do I Need to Back Up? Moving or Copying AutoCorrect EntriesUSE THE AUTOCORRECT UTILITY FROM THE MVP SITEThis utility supplants and improves the utility from Microsoft. It copies your AutoCorrect Entries into a Word table. They can be viewed and edited in that table. Then the utility can put your edits into your AutoCorrect all at once. You can also copy the table to a different computer and use the utility to copy your AutoText onto that computer. Easy to use. Free! The version of this utility for Word 2007 - 2024 can be found on Jay Freedman's site as AutoCorrect2007.zip and works with Word 2007-2024. Another utility to manage AutoCorrect entries can be found on Greg Maxey's
site:
AutoCorrect Utility Manager
AutoText may be more suited to your purposes than AutoCorrectFor boilerplate, AutoText is usually superior to AutoCorrect because it is more easily edited and transferred from computer to computer, and any size limitation is related to storage space. AutoText resides in templates, rather than in a special file. AutoText is one of many types of Building Blocks in ribbon versions of Word. AutoText is a way to store parts of a Word document for re-use. You can, for example, create a library of boilerplate paragraphs for business letters, or keep a handy selection of headers and footers. An AutoText entry can store anything a Word document can contain, such as formatted text, pictures, and fields. Word comes with a number of predefined AutoText entries, and you can add as many as you like. (AutoText cannot store working Content Controls, for some reason. Many other Building Blocks can hold content controls.) As of this writing (February 2022) AutoText is the only Building Block used on the Mac versions of Word. For the Windows version additional building blocks galleries are available. These can be mimicked to some extent on Word for the Mac. See John Korchok's article Custom Content in AutoText Gallery. If your AutoText is stored in your Normal.dotm template in Word 2010 it gives you an AutoComplete "tooltip" previewing what the replacement text will be before it makes the replacement. (In versions earlier than Word 2007 and beginning again in Word 2013, it shows this tooltip if the AutoText/Building Block is stored in the Normal.dotm template (the default for AutoText), the document template, or another template loaded as an Add-In.) The tooltip shown here is for the AutoText entry named "ATEntry1" and the contents are "This is an AutoText entry tooltip." It is shown after the first four letters of the name: "aten." Note that this is not case-sensitive. In Word 2007 there are no tooltips for AutoText entries. In Word 2013 the full tooltip (AutoComplete) feature was restored and appears for any AutoText or other Building Block stored in the attached template, normal.dotm, and other global templates (but not in the building blocks files which are not treated as Add-In global templates). AutoComplete works with other Building Blocks as well, not just AutoText. The AutoComplete feature does not work with building blocks in a template that is stored in one of the building blocks folders; the F3 key, though, does work. AutoComplete works with Building Blocks (including AutoText) in your Normal.dotm template or in a Global Template stored in your Word Startup Folder. With AutoText (or other Building Blocks) stored in these templates if you type the first four letters of your AutoText entry name you'll see a tooltip showing the entire entry (or its start). If you press Enter when the tooltip is showing, you'll get your replacement entry. Especially in Word 2007-2024, if the tooltip is not showing but you've typed the first four letters, try pressing the F3 key. Note, if the first four letters are not unique to one AutoText entry, you'll need to type enough to have a unique entry name. You can also attach a keyboard shortcut to your AutoText entries. See this Microsoft Answers thread on the appearance (or not) of the tooltip. Either way you use AutoText you will probably find it useful. Continue using it and you will develop a whole library of boilerplate. In WordPerfect this function was filled with macros; in Word it is AutoText. (While Word uses macros, they fulfill a different purpose and are ill-suited for simple recording or creation of boilerplate.) In some early versions of Word (before Word 6), the AutoText feature was called the Glossary. In at least one current (2016) language version it is called Gjossario. See also my article: AutoComplete - for AutoText and Other Building Blocks Where Are AutoText Entries and Other Building Blocks Stored?AutoText Entries and other Building Blocks are kept in templates. AutoText is stored in the normal template by default but is often better kept in a document template or in a different global template. In Ribbon versions of Word (2007-2024) AutoText is still stored in templates, but is a part of the concept "Building Blocks." In Word 2007 AutoText entries are stored by default in a separate building blocks file but can be stored in other templates, including normal.dotm. In all other versions of Word, the default storage location for AutoText is the normal template. In Word 2007 and later the name of the default building blocks storage file is "Building Blocks.dotx." That is the default storage location for user-created Building Blocks other than AutoText. In Word 2010-2024 there is a separate file for Building Blocks that come with Word: "Built-In Building Blocks.dotx." These files are stored in a sub folder of the User's Application Data folder. The precise building blocks storage folder depends on both the version of word and the operating system. These are hidden system folders Note that Outlook AutoText entries are stored in the NormalEmail.dotm template. You can make them available in Word by placing a shortcut to that template in your Word Startup Folder. Windows XP Location: Windows Vista & 7-10 Location: The 1033 is the English-language version. Within that folder there may be additional folders for the version of Word. Again, that is the location for the default storage location. Any template stored in the Document Building Blocks folder will share building blocks with all files. If put in a subfolder, it should share the restrictions of that subfolder. That is, if the template is placed in the 1033 folder and the user is using a non-English language proofing set, the template may not be available, while if it were in the general Building Blocks folder (one level up) it would be available. Building blocks including AutoText (Word 2007-2024) must be stored in templates. In Ribbon versions of Word, they can be stored in either dotx or dotm templates. For the template to have macros, it must be a dotm template and should not be stored in the Building Blocks folder if you want access to the macros. Templates to hold building blocks may be stored in the Document Building Blocks folder. They need not be stored in the same language- or version-specific folder as the built-in building blocks file. They can be stored in that folder and if they are, should carry the language restrictions of that containing folder. Building Blocks stored in the building blocks folders are not treated as global templates. This is true even though the building blocks they contain are available in any other document or template (so long as there is not a naming conflict). In Word 2013 and later AutoComplete works for building blocks that are stored in (1) normal.dotm, (2) other global templates, and (3) the attached document template. The AutoComplete feature does not work with building blocks in a template that is stored in one of the building blocks folders; the F3 key, though does work. Saving AutoText or Other Building BlocksIn order to save anything as AutoText or another type of Building Block (including textboxes), what you want to save must be selected. The quick way to get to the save dialog is to press Alt+F3. When you use Alt+F3 to save something as AutoText (or another type of Building Block) Word gives you a dialog box to let you assign a name to the AutoText entry. The default name is the actual text, but something else may be a better name. In Word 2007 and later that dialog gives you options for where the AutoText is to be stored, again, in the normal template by default. You can tell Word to save the selection in a different Building Blocks Gallery and assign a category. You can save a description as well.
In earlier versions (non-Ribbon) Alt+F3 does not give storage options and you will be saving in normal.dot.
With these non-ribbon versions of Word, with the text you want to save selected, your can save in the normal template and use the Organizer to move the AutoText to a different template. Otherwise, you can save directly in a different template. This is a bit more complex. You need to go to AutoText under the Insert Menu and pick the general AutoText at the top. This will give you the following dialog from the AutoCorrect Options for AutoText:
The options you will have for storage locations for AutoText include the default normal template, the attached document template if that is different, and loaded Add-In templates that already have AutoText. The currently open document is not an option because documents cannot hold AutoText or other Building Blocks. If you first save your document as a template, it can then hold AutoText. See Where Can Building Blocks Be Stored for more on the options for storage. The Macintosh version has similar dialogs for saving AutoText. It does not sort by categories but does let you pick templates. As of this writing (February 2022) AutoText is the only Building Block used on the Mac versions of Word. For the Windows version additional building blocks galleries are available. These can be mimicked to some extent on Word for the Mac. See John Korchok's article Custom Content in AutoText Gallery.
Incorporating AutoText or other Building Blocks in Templates with AutoText Fields, AutoTextList Fields, or Building Block Content Controls
AutoCorrect is mostly kept in separate .acl files. Formatted AutoCorrect entries, though are stored in Normal.dot. (Normal.dotm in Word 2007-2024) More. AutoFormat is built into Word and switched on or off with options settings. See Tame AutoFormat. Assign Your AutoText Entries (Building Blocks) to a Key or Key CombinationThe following is taken from my response to someone on a newsgroup who wanted to assign keystrokes to superscripted numbers 1-4. She had asked to replace four of the symbols over the numbers on the keyboard with these and had been told by another (knowledgeable) user that this was not a good idea. Start Word. If you are already in Word, exit and restart it. Then, type five words in a new document. If you will only be using these in documents based upon a particular template, base your new document on that template. If you want to be able to share these with someone else or move them to a different computer, you do not want to store them in Normal.dot. See Template Basics information on Global templates. If these are not for use with only one particular template, my recommendation would be that you save your new document as a template so it can hold the AutoText. Then insert the four superscripted numbers as if they were footnote references (that you were manually typing in rather than inserting footnotes). Then, in turn, select each of the superscripted characters and save them as AutoText entries named spr1, spr2, spr3 and spr4. (Alt+F3) Make sure that the AutoText entries are being saved in the proper template if you are basing your documents on a special template. Then select the fifth word and assign it to autotext as spr5. Once you have the AutoText entries, you are ready to assign them to keys. The method we will use will replace only one of your keyboard's built-in key assignments for all five of the AutoText entries. (Ctrl+Shift+Alt+NumPad+) (Word 97-2003) Tools => Customize => Keyboard (button)
(Word 2007) Modify the QAT => Keyboard Shortcuts Customize... (Word 2010 and later) Customize the Ribbon => Keyboard Shortcuts Customize...
Next repeat this process for your other four AutoText entries, typing the appropriate number for each. Then click on the close button and close the customize dialog box as well. Test your keys out. First press Alt+S. Nothing will seem to happen. Then type a 1. It will be superscripted. Type something else immediately after the 1. That should not be superscripted. Test each of your numbers. Finally, test it using the number 5. We put in this last entry so that you could see that it is indeed using your AutoText, not just altering the numbers that we happened to use as trigger keys. If you want, you can now go back into the AutoText dialog box and delete spr5. It has served its purpose. You could assign these autotext entries to any keystroke or keystroke combination (including the keys you originally requested). You should be very careful, though, about replacing key bindings because it can be very tricky to figure out what is going on when you forget about them (or if someone else tries to use your computer). You may have noted that you could use the Customize Keyboard dialog to assign not only AutoText but macros, styles, fonts, or any Word command to a key. You might want to copy these instructions to a text file called something like "Word key assignments.txt" and keep it, with any notes you care to make, so that you can backtrack later. Note this works in all versions of Word. However if more than one AutoText entry or Building Block has the same name you can still do it, but Word will pick one of the entries to assign. I know of no good way to predict which entry that will be. In the screenshot above #7 shows a gallery and category for the AutoText entry. (There are multiple entries with that same name, only one is shown.) For instances with multiple entries with the same name, see below on using vba to insert building blocks. You can also assign keyboard shortcuts to macros. See also Assigning Keyboard Shortcuts in Microsoft Word 2007-2024 (365).
AutoText (Building Blocks) Keyboard Shortcuts Built into Word
Moving/Copying AutoText EntriesUsing the Organizer to Copy AutoTextYou can copy AutoText between templates. One of the most effective ways to do this is through the Organizer. The Organizer is a tool built into Word that allows you to quickly copy Styles, AutoText, Toolbars and Macros. In Word 97-2003, you can access the Organizer in one of three ways: Tools => AutoCorrect => AutoText (tab) => Organizer (button) Format => Style... => Organizer (button) Tools => Templates and Add-Ins... => Organizer (button) from the Format menu, choose Style and click Organizer; or from the Tools menu, choose Templates and Add-Ins and click Organizer. This gets you the following dialog box which controls AutoText, Styles, Toolbars and Macros:
In Word 2007 - Word 2024 You can use the Building Blocks Organizer found under the Quick Parts drop-down on the Insert tab. This lets you move or modify a building block/AutoText but does not let you copy one unless you tell Word to not save changes to the template that originally had the building block. The screenshot below shows the Building Blocks Organizer with the Modify Building Block dialog (triggered by the Edit Properties button shown).
You can also access this dialog by right-clicking on any Building Blocks gallery item and choosing the "Organize and Delete" choice from the pop-up menu.
To move a building block using the Building Blocks Organizer, select it and edit the properties to get to the Modify dialog. You can change the storage location to any template that currently has at least one building block and which is loaded as an Add-In. When you exit Word, you will be asked if you want to save changes to your template containing building blocks. If you say "no" to the template that you moved the building block from and "yes" to the template you moved the building block to, you will have copied the building block rather than just moving it. To copy a building block using the tools in Word 2007-2024, you can also copy the template that holds the building block to another template name. Then open the copy and use the Building Blocks organizer to modify it to use the template you want to hold it. (You may then have two building blocks with the same name. This makes maintenance difficult and can give unpredictable results.) Instead, for Word 2007 - 2024, I recommend using Greg Maxey's free Add-In that gives you the following dialog boxes for all of your building blocks. Like the original Organizer, it allows copying and manipulation of multiple entries at the same time. The Building Blocks Organizer that comes with Word lets you work on one entry at a time when trying to move entries from template to template. If you use the link above, you'll find the download at the bottom of a page explaining the features as well as exploring Building Blocks. Greg Maxey's Add-In adds a powerful (optional) ribbon tab. The dialog above (organizer) is one of the buttons on the left side of that ribbon. The Add-In's Ribbon tab is controlled from the dialog box shown below. It lets you change the name of any of the galleries displayed on the tab and decide whether or not to display a particular gallery on the tab at all. You can even set it to not display the tab at all! The Add-In also includes a powerful Building Blocks Loader that lets you bulk load items as Building Blocks. In my opinion, these tools should have been included in Word 2007. If MS eventually adopts them, I hope they compensate Mr. Maxey! Anyone making extensive use of building blocks should have his (free) Add-In. If they use it much, they should send him a donation. I did! See also Autotext backup and restore by Graham Mayor - works only on AutoText stored in the normal.dotm template but works very well for that.
Practice: Copy AutoText Using the Organizer
In Word 2010 there can be advantages to storing AutoText in normal.dotm in that you can use the tooltip feature. I like to maintain a backup copy of normal.dotm when I do this. That is a good idea anyway. (The tooltip feature is not available in Word 2007; in Word 2013 and later, it is available for any AutoText stored in the attached template or in loaded global templates, but not that stored in the Building Blocks folder.) Editing/Modifying Building Blocks including AutoText
Where Can Building Blocks Be Stored? (Word 2007-2024)
For an example of a building blocks template that acts as an Add-In see the Word 2003 WordArt Building Blocks Add-In. See Saving AutoText above for more on the use of the Alt+F3 keyboard shortcut. See also Moving / Copying Customizations (including AutoText) to another template. Here is an example of a building blocks organizer screen for footers showing footers coming from the Word 2013 Built-In Building Blocks, the Word 2010 Built-In Building Blocks, and my Page X of Y Building Blocks Add-In. The sources are shown in the Template column.
Default Storage Templates - depends on how you get to the Create Building Block dialog
Where in a template are building blocks stored (for techies only)?In the XML in the document.xml in the Gallery folder in the Word folder. Look for <w.docPart> to start a building block.
|
Note The "Rog" in this example is the name of the Interrogatory numbering scheme. This name will keep this numbering scheme unique from any other schemes that may be running in the document. See Tip below for more information. |
To use the AutoText entry, simply type rog and press F3.
Tip Follow the same steps (above) to create Request for Production or Request for Admissions. The only difference would be in Step 3, you would change the "rog" to "rpf" or "rfa". This will keep unique numbering schemes running in the same document. Therefore, you could have an Interrogatory No.1 as well as Request for Production No.1. Keep in mind that if you cut, copy or paste sequence codes, you'll need to select them and press F9 to update the field codes. They do not update automatically. |
You can print all AutoText entries (in the attached template and any global templates) using:
File > Print
In the print dialog box toward the lower left you will see "Print what" answered with "Document." Change that to "AutoText entries." Click on OK.
Use the AutoCorrect backup utility you can download from the MVP FAQ site to create a table with your AutoCorrect entries. Print that table. See also AutoCorrect Utility Manager.
Many of the AutoFormat as You Type Options cause unexpected changes in your document. While there are times when they are useful, those times are not frequent for your author or many experienced Word users. Here are screenshots showing the ones that I uncheck, and those that I leave on. These are from Word 2003 and Word 2010.
See Tame AutoFormat and How To Turn Off AutoFormat Options and AutoCorrect and AutoText (video).
You may want to use AutoCorrect rather than AutoFormat as you Type for Fractions and Em-and En-dashes.
If you found your way here, you may also be looking at a couple of Auto
features with
Styles.
Generally you do not want to be using either of these
settings/features.
A setting in a style to Automatically update the style based on typing (see Whole Document Reformatted by Suzanne Barnhill, MVP ) This is not the same as the Define Styles Based on formatting in AutoFormat as you type. | |
A setting to update styles in the document to the ones currently in the template. (see What happens when I send my document to someone else? Will Word mess up my formatting? by Shauna Kelly, MVP.) |
Recording a Macro
Recording a macro will work, to a limited extent. Recorded macros will not work on someone else's system even if they have the same building blocks or even if they are a different user on the same computer. Recorded macros will not work if the template contains more than one building block with the same name, even if they are different types. Note that the file that comes with Word "Built-In Building Blocks.dotx" has many building blocks with the same names. You can use the Building Blocks Organizer and sort by name to see if there are multiple building blocks with the same name and in the same template.
Because of these limitations, often you will need to actually write a macro.
However, you can try recording one. The key is to use the Building Blocks Organizer to insert the Building Block when recording the macro, rather than a shortcut or another gallery/menu.
Any macro, recorded or written, should be stored in the same template that holds the building block. That way, if the macro is available, the building block is available.
Writing a Macro
To do this, you need to know:
Building Block Name = "MyBB" (example in this macro, change to fit)
Situation 1 and 1a have the Building Block and the macro in the same template. This simplifies coding because a macro can always tell the name and location of the template that holds it. That information is required to use a macro to insert a building block.
Situation 1 - template holds both the building block and the macro
Here is the macro to insert that uniquely-named building block at the insertion point in the document:
Sub InsertMyBB1()
' http://www.addbalance.com/usersguide/autotextautocorrect.htm#UsingVBABuildingBlock
' Situation 1 - template holds both the building block and the macro
' Updated 8 October 2021
'
' Will not work if there are multiple building blocks with the same name in the template! See InsertMyBB1a below.
' Template holds both code and building block
' Here is the macro to insert that uniquely-named building block at the insertion point in the document:
'
Const sBBName As String = "MyBB" 'use the name of your building block instead of "MyBB"
Dim oRange As range
Set oRange = Selection.range ' set a real range for better performance, not depending on selection
'
On Error GoTo Oops
Application.Templates.LoadBuildingBlocks ' Thank you Timothy Rylatt
Application.Templates(ThisDocument.fullname).BuildingBlockEntries(sBBName).Insert Where:=oRange, _
RichText:=True ' Insert MyBB Building Block
Set oRange = Nothing
Exit Sub ' We're done here
Oops: ' Didn't work - building block not there!
MsgBox Prompt:="The Building Block " & sBBName & " cannot be found in " & _
ThisDocument.Name & ".", title:="Didn't Work!"
Set oRange = Nothing
On Error GoTo -1
End SubThis and the following macro are both contained in a demonstration template that can be downloaded from my downloads page.
Situation 1a - template holding building blocks and macro in same template - multiple building blocks with the same name
In this situation, the previous macro would confuse Word and give unpredictable (to the user) results. In this case, the macro needs to know both the gallery and category of the building block. The following macro assumes that the building block is stored in the AutoText gallery and in the General category. You can find the name of the gallery and category using the Building Blocks Organizer. Category names are plain text. Galleries are referenced in vba as Building Block Types and use constants. You can find a list of the constants for the different galleries here.
Sub InsertMyBB1a()
'
' Assumes that the Building Block is of the type AutoText (wdTypeAutoText) in Category "General"
' See https://msdn.microsoft.com/en-us/library/bb243303(v=office.12).aspx
'
' This is based in part upon contributions from Greg Maxey and Jay Freedman - any errors remain mine
' Written by Charles Kenyon April 2021, updated October 2021
'
Const sBBName As String = "MyBB" 'use the name of your building block instead of "MyBB"
Const sTempName As String = ThisDocument.fullname ' puts name and full path of template in string
'
Dim oBB As BuildingBlock
Dim oRange As range
Set oRange = Selection.range ' set a real range for better performance, not depending on selection
'
On Error Resume Next
Application.Templates.LoadBuildingBlocks ' Thank you Timothy Rylatt
Set oBB = Application.Templates(sTempName).BuildingBlockTypes(wdTypeAutoText) _
.Categories("General").BuildingBlocks(sBBName)
If err.Number = 0 Then
oBB.Insert oRange, True
Else
MsgBox Prompt:="The Building Block '" & sBBName & "' cannot be found in " & _
ThisDocument.Name & ".", Title:="Didn't Work!"
End If
lbl_Exit:
On Error GoTo -1
Set oBB = Nothing
Set oRange=Nothing
End Sub
This and the preceding macro are both contained in a demonstration template that can be downloaded from my downloads page.
Situation 2 - template holding building block is in Word Startup Folder and named MyBBTemplate.dotx
This template, for some reason, does not hold the macro, it is in a separate template. We know the name of the BB container template. The name of the template containing the macro does not matter for our purposes.
Sub InsertMyBB2()
' Will not work if the Startup Folder is the root directory of a drive, i.e. C:\
' For use with building block stored in a template loaded in the Word Startup Folder that does NOT hold this macro
' Will not work if there are multiple building blocks with the same name in the template!
'
Const sBBName As String = "MyBB" 'use the name of your building block instead of "MyBB"
Const sTempName As String = "MyBBTemplate.dotx" 'use the name of your template instead of "MyBBTemplate.dotx"
Dim oRange As range
Set oRange = Selection.range ' set a real range for better performance, not depending on selection
'
On Error GoTo NoStartupPath
Const sStartupFolder As String = Application.Options.DefaultFilePath(wdStartupPath)
'
On Error GoTo Oops ' error handler
Application.Templates.LoadBuildingBlocks ' Thank you Timothy Rylatt
Application.Templates(sStartupPath & "\" & sTemplateName).BuildingBlockEntries(sBBName) _
.Insert Where:=oRange, RichText:=True ' Insert MyBB Building Block
Exit Sub ' We're done here
NoStartupPath:
On Error GoTo -1
MsgBox Prompt:="No Startup Folder Set in Options"
Set oRange=Nothing
Exit Sub
Oops: ' Didn't work - building block not there!
MsgBox Prompt:="The Building Block " & sBBName & " cannot be found in " & _
sTemplateName & ".", Title:="Didn't Work!"
set oRange=Nothing
On Error GoTo -1
End SubVariation inserting in header instead of at insertion point
Sub InsertHeaderBBFirstPage()
' Charles Kenyon 4 April 2022
' Inserts building block from template Add-In in the first-page header
' Will not work if the Startup Folder is the root directory of a drive, i.e. C:\
' For use with building block stored in a template loaded in the Word Startup Folder that does NOT hold this macro
' Will not work if there are multiple building blocks with the same name in the template!
' Will not work if the template is not really in the Startup Folder (i.e. with a shortcut/alias)
'
' The following command activates the First-Page Headers and Footers
' It is not required for this to work but if that is not active the user
' will not see it and it will not print.
ActiveDocument.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = True
'
Const sBBName As String = "MyBB" 'use the name of your building block instead of "MyBB"
Const sTempName As String = "MyBBTemplate.dotx" 'use the name of your template instead of "MyBBTemplate.dotx"
Dim oRange As range
' Set target range as the first-page header of section 1
Set oRange = Selection.Sections(1).Headers(wdHeaderFooterFirstPage). _
range.Paragraphs(1).range
' To insert in footer instead, would use
' Sections(1).Footers(wdHeaderFooterFirstPage).range.Paragraphs(1).range
'
On Error GoTo NoStartupPath
Dim sStartupFolder As String
Let sStartupFolder = Application.Options.DefaultFilePath(wdStartupPath)
'
On Error GoTo Oops ' error handler
Application.Templates.LoadBuildingBlocks ' Thank you Timothy Rylatt
Application.Templates(sStartupFolder & "\" & sTemplateName).BuildingBlockEntries(sBBName) _
.Insert Where:=oRange, RichText:=True ' Insert MyBB Building Block
Exit Sub ' We're done here
NoStartupPath:
On Error GoTo -1
MsgBox Prompt:="No Startup Folder Set in Options"
Set oRange = Nothing
Exit Sub
Oops: ' Didn't work - building block not there!
MsgBox Prompt:="The Building Block " & sBBName & " cannot be found in " & _
sTemplateName & ".", title:="Didn't Work!"
Set oRange = Nothing
On Error GoTo -1
End SubSituation 3 - Insert a building block with a unique name at a named bookmark, regardless of BB storage location
This macro does NOT care where the building block is stored but its name must be unique to have predictable results.
Sub InsertMyBuildingBlock_Bookmark()
' Charles Kenyon 09 April 2021
' based on Graham Mayor's macro at
' http://www.gmayor.com/word_vba_examples_3.htm
' In addition to checking the active template, add-in templates and the normal template,
' this macro looks in the building blocks.dotx template.
' Building Block name must be unique!
'
Const BookMarkNAME As String = "delete" ' use the name of the building block - make variable if multiple bookmarks
'
Dim oTemplate As Template
Dim oAddin As AddIn
Dim bFound As Boolean
Dim oRng As range
Dim i As Long
'Define the required building block entry
Const strBuildingBlockName As String = "Building Block Name" ' CHANGE TO YOUR BUILDING BLOCK'S NAME
' Set the range
Set oRng = ActiveDocument.Bookmarks(BookMarkNAME).range
'Set the found flag default to False
bFound = False
'Ignore the attached template for now if the
'document is based on the normal template
Application.Templates.LoadBuildingBlocks ' Thank you Timothy Rylatt
If ActiveDocument.AttachedTemplate <> NormalTemplate Then
Set oTemplate = ActiveDocument.AttachedTemplate
'Check each building block entry in the attached template
For i = 1 To oTemplate.BuildingBlockEntries.Count
'Look for the building block name
'and if found, insert it.
If oTemplate.BuildingBlockEntries(i).Name = strBuildingBlockName Then
oTemplate.BuildingBlockEntries(strBuildingBlockName).Insert _
Where:=oRng
'Set the found flag to true
bFound = True
'Clean up and stop looking
GoTo lbl_Exit
End If
Next i
End If
'The entry has not been found
If bFound = False Then
For Each oAddin In AddIns
'Check currently loaded add-ins
If oAddin.Installed = False Then Exit For
Set oTemplate = Templates(oAddin.Path & _
Application.PathSeparator & oAddin.Name)
'Check each building block entry in the each add in
For i = 1 To oTemplate.BuildingBlockEntries.Count
If oTemplate.BuildingBlockEntries(i).Name = strBuildingBlockName Then
'Look for the building block name
'and if found, insert it.
oTemplate.BuildingBlockEntries(strBuildingBlockName).Insert _
Where:=oRng
'Set the found flag to true
bFound = True
'Clean up and stop looking
GoTo lbl_Exit
End If
Next i
Next oAddin
End If
'The entry has not been found. Check the normal template
If bFound = False Then
For i = 1 To NormalTemplate.BuildingBlockEntries.Count
If NormalTemplate.BuildingBlockEntries(i).Name = strBuildingBlockName Then
NormalTemplate.BuildingBlockEntries(strBuildingBlockName).Insert _
Where:=oRng
'set the found flag to true
bFound = True
End If
Next i
End If
'If the entry has still not been found
'finally check the Building Blocks.dotx template
If bFound = False Then
Templates.LoadBuildingBlocks
For Each oTemplate In Templates
If oTemplate.Name = "Building Blocks.dotx" Then Exit For
Next oTemplate
For i = 1 To Templates(oTemplate.fullname).BuildingBlockEntries.Count
If Templates(oTemplate.fullname).BuildingBlockEntries(i).Name = strBuildingBlockName Then
Templates(oTemplate.fullname).BuildingBlockEntries(strBuildingBlockName).Insert _
Where:=oRng
'set the found flag to true
bFound = True
'Clean up and stop looking
GoTo lbl_Exit
End If
Next i
End If
'All sources have been checked and the entry is still not found
If bFound = False Then
'so tell the user.
MsgBox "Entry not found", _
vbInformation, _
"Building Block " _
& Chr(145) & strBuildingBlockName & Chr(146)
End If
lbl_Exit:
set oTemplate = Nothing
set oRng = Nothing
End SubFor more thoughts/ideas on inserting a building block at a bookmark, see this thread:
Updating bookmark with multiple building blocks based on checkboxHere is a variation inserting the Building Block in the First-Page Header - the only difference is the range
Sub InsertMyBuildingBlock_Header1stPage()
' Charles Kenyon 04 April 2022
' based on Graham Mayor's macro at
' http://www.gmayor.com/word_vba_examples_3.htm
' In addition to checking the active template, add-in templates and the normal template,
' this macro looks in the building blocks.dotx template.
' Building Block name must be unique!
'
' NOTE - only sets first section of document to have a different first page
'
ActiveDocument.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = True
'
Dim oTemplate As Template
Dim oAddin As AddIn
Dim bFound As Boolean
Dim oRng As range
Dim i As Long
'Define the required building block entry
Const strBuildingBlockName As String = "Building Block Name" ' CHANGE TO YOUR BUILDING BLOCK'S NAME
' Set the range
Set oRng = Selection.Sections(1).Headers(wdHeaderFooterFirstPage). _
range.Paragraphs(1).range
'Set the found flag default to False
bFound = False
' Ignore the attached template for now if the
'document is based on the normal template
Application.Templates.LoadBuildingBlocks ' Thank you Timothy Rylatt
If ActiveDocument.AttachedTemplate <> NormalTemplate Then
Set oTemplate = ActiveDocument.AttachedTemplate
'Check each building block entry in the attached template
For i = 1 To oTemplate.BuildingBlockEntries.Count
'Look for the building block name
'and if found, insert it.
If oTemplate.BuildingBlockEntries(i).Name = strBuildingBlockName Then
oTemplate.BuildingBlockEntries(strBuildingBlockName).Insert _
Where:=oRng
'Set the found flag to true
bFound = True
'Clean up and stop looking
GoTo lbl_Exit
End If
Next i
End If
'The entry has not been found
If bFound = False Then
For Each oAddin In AddIns
'Check currently loaded add-ins
If oAddin.Installed = False Then Exit For
Set oTemplate = Templates(oAddin.Path & _
Application.PathSeparator & oAddin.Name)
'Check each building block entry in the each add in
For i = 1 To oTemplate.BuildingBlockEntries.Count
If oTemplate.BuildingBlockEntries(i).Name = strBuildingBlockName Then
'Look for the building block name
'and if found, insert it.
oTemplate.BuildingBlockEntries(strBuildingBlockName).Insert _
Where:=oRng
'Set the found flag to true
bFound = True
'Clean up and stop looking
GoTo lbl_Exit
End If
Next i
Next oAddin
End If
'The entry has not been found. Check the normal template
If bFound = False Then
For i = 1 To NormalTemplate.BuildingBlockEntries.Count
If NormalTemplate.BuildingBlockEntries(i).Name = strBuildingBlockName Then
NormalTemplate.BuildingBlockEntries(strBuildingBlockName).Insert _
Where:=oRng
'set the found flag to true
bFound = True
End If
Next i
End If
'If the entry has still not been found
'finally check the Building Blocks.dotx template
If bFound = False Then
Templates.LoadBuildingBlocks
For Each oTemplate In Templates
If oTemplate.Name = "Building Blocks.dotx" Then Exit For
Next oTemplate
For i = 1 To Templates(oTemplate.fullname).BuildingBlockEntries.Count
If Templates(oTemplate.fullname).BuildingBlockEntries(i).Name = strBuildingBlockName Then
Templates(oTemplate.fullname).BuildingBlockEntries(strBuildingBlockName).Insert _
Where:=oRng
'set the found flag to true
bFound = True
'Clean up and stop looking
GoTo lbl_Exit
End If
Next i
End If
'All sources have been checked and the entry is still not found
If bFound = False Then
'so tell the user.
MsgBox "Entry not found", _
vbInformation, _
"Building Block " _
& Chr(145) & strBuildingBlockName & Chr(146)
End If
lbl_Exit:
Set oTemplate = Nothing
Set oRng = Nothing
End SubSituation 4 - template holding building block is "Building Blocks.dotx" in the building blocks storage location
This template also does not hold the macro because templates in the building blocks folder do not contribute macros to Word even if they contain them. This macro incorporates code from Greg Maxey and Jay Freedman given in this thread. Building Blocks.dotx is the name of the template used, by default, to store custom building blocks other than AutoText. It is stored, by user, in a language-dependent, version-dependent folder. This macro is intended to retrieve the building block regardless of the language or version.
Sub InsertMyBB3()
' Based on code by Greg Maxey and Jay Freedman
' For use with building block stored in the default custom building blocks file "Building Blocks.dotx"
' Will not work if there are multiple building blocks with the same name in the template!
'
Const sBBName As String = "MyBB" 'use the name of your building block instead of "MyBB"
Const sTempName As String = "Building Blocks.dotx" 'use the name of your template instead of "MyBBTemplate.dotx"
Set oRange = Selection.Range
'
Templates.LoadBuildingBlocks ' in case building blocks not yet accessed
'
On Error GoTo Oops ' error handler
'
Application.Templates.LoadBuildingBlocks ' Thank you Timothy Rylatt
Application.Templates(sStartupPath & "\" & sTemplateName).BuildingBlockEntries(sBBName) _
.Insert Where:=oRange, RichText:=True ' Insert MyBB Building Block
Set oRange = Nothing
Exit Sub ' We're done here
Oops: ' Didn't work - building block not there!
MsgBox Prompt:="The Building Block " & sBBName & " cannot be found in " & _
sTemplateName & ".", Title:="Didn't Work!"
On Error GoTo -1
Set oRange = Nothing
End SubWarning on Multiple Building Blocks with the same name. See screenshot below!
If there are multiple building blocks that have the same name in the same template, the results will be unpredictable unless instead of BuildingBlockEntries the Collection of BuildingBlockTypes is used along with the specific category. The ordinary user will not be aware of these so the developer must set things up. Word has 35 types that correspond to the 35 galleries of building blocks. You can find a list here. See also What happens if two building block entries have the same name? below.
At this point, I will refer you to the thread that started this all if you want your entries in a different template (or want to get them from the Built-In Building Blocks). For your own use, you can record the insertion of a building block from any template. The problem comes when you try to transfer the macro and building block to another computer or user. (Again, see the idea of storing the macro and building block in the same template.)
I often use AutoText Fields in my document templates. These work not only with AutoText but also with other Building Blocks. The AutoText itself is stored in either document or Global Templates. That way there is one central repository for the language or images. However, AutoText Fields are not necessarily automatically updated. In addition it is important to not send a document with an AutoText Field to someone who does not have access to the Global template, the field needs to be unlinked so that just the AutoText, itself, is what is in the document. This is also important for maintaining archival documents so the language does not change when the document is opened.
I handle this with an AutoNew macro in the document templates. That calls on two macros in the global template containing the AutoText when a new document is created based on the document template. Separate similar macros would be needed for AutoTextList fields. These will not do anything to Building Blocks Gallery Content Controls.
Here are the macros:
AutoNew Macro (in the document templates)
Sub AutoNew()
' Place in document templates containing AutoText Fields - runs when new document created
' Charles Kenyon November 12, 2020
Application.Run UpdateAllAutoText
Application.Run UnlinkAllAutoText
End SubUpdate all AutoText Fields macro (in global template)
Sub UpdateAllAutoText()
' Update all AutoText fields in a document, even if in headers/footers or textboxes
' based on code at https://gregmaxey.com/word_tip_pages/word_fields.html
' November 12, 2020 Charles Kenyon
Dim rngstory As Word.range
Dim lngValidate As Long ' do not know purpose of this - CK
Dim oShp As Shape
Dim oStory As range
Dim oField As Field
lngValidate = ActiveDocument.Sections(1).Headers(1).range.StoryType ' do not know purpose of this
For Each rngstory In ActiveDocument.StoryRanges
'Iterate through all linked stories
For Each oField In oStory.Fields
If oField.Type = wdFieldAutoText Then oField.Update
Next oField
Do
On Error Resume Next
For Each oField In rngstory.Fields
If oField.Type = wdFieldAutoText Then oField.Update
Next oField
Select Case rngstory.StoryType
Case 6, 7, 8, 9, 10, 11
If rngstory.ShapeRange.Count > 0 Then
For Each oShp In rngstory.ShapeRange
If oShp.TextFrame.HasText Then
For Each oField In oShp.TextFrame.Fields
If oField.Type = wdFieldAutoText Then oField.Update
Next oField
End If
Next
End If
Case Else
'Do Nothing
End Select
On Error GoTo 0
'Get next linked story (if any)
Set rngstory = rngstory.NextStoryRange
Loop Until rngstory Is Nothing
Next
'
Set oStory = Nothing
Set oField = Nothing
Set rngstory = Nothing
Set oShp = Nothing
End SubSub AutoTextFieldUpdateAllStory()
' Written by Charles Kyle Kenyon 9 March 2021
' assistance from Jezebel
' All Story Field Updater - AutoText fields
Dim oField As Field
Dim oStory As range
' On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
Do
For Each oField In oStory.Fields
If oField.Type = wdFieldAutoText Then
oField.Update
End If
Next oField
Set oStory = oStory.NextStoryRange
Loop Until oStory Is Nothing
Next oStory
Set oStory = Nothing
Set oField = Nothing
On Error GoTo -1
End SubMacro to Unlink Fields (in global template that holds AutoText or other Building Blocks)
Sub UnlinkAllAutoText()
' Unlink all AutoText fields in a document, even if in headers/footers or textboxes
' Based on code at http://www.gmayor.com/installing_macro.htm
' Charles Kenyon
' 2 Sept 2020
'
Dim oStory As range
Dim oField As Field
'
For Each oStory In ActiveDocument.StoryRanges
For Each oField In oStory.Fields
If oField.Type = wdFieldAutoText Then oField.Unlink
Next oField
'
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
For Each oField In oStory.Fields
If oField.Type = wdFieldAutoText Then oField.Unlink
Next oField
Wend
End If
'
Next oStory
'
Set oStory = Nothing
Set oField = Nothing
End Sub
Weird formatting?
No tooltip is showing for my AutoText so I can't press Enter and insert it. AutoComplete problems
In Word 2010 this indicates that your AutoText is stored somewhere other than normal.dotm. This is perfectly acceptable but you can't use the Enter key or see the tooltip. Once you have typed at least four letters of the name, try pressing the F3 key to insert your AutoText. Long term, you can use the organizer to insert it. Word 2013 allowed tooltips for other Global Templates. Note that while AutoComplete works with Building Blocks other than AutoText, it only works with those stored in global or document templates (including the Normal template). AutoComplete does not work with those stored in Building Blocks folders.
In Word 2007 no tooltips show for AutoText entries. Period. You can still use the F3 key to enter AT entries in your text.
In Word 97-2003 this may indicate multiple AutoText entries with the same entry name or that you haven't typed enough of the name for Word to distinguish the entry you want from a different one with the same beginning to the name.
Missing Page Number / Header / Footer Commands - greyed out - Charles Kenyon
What happens if two building blocks entries have the same name?
Word will allow two different entries to have the same name so long as they are either stored in different templates, different Galleries in the same template or different Categories in the same Gallery. No error message or query will be generated when you try to save one with the same name as another unless you are trying to save in the same template, Gallery, and Category. In that case, you will be asked if you want to redefine the entry. Generally you want to have different names for different entries.
The F3 key after typing an entry name will call not only AutoText but also other Building Blocks.
The AutoText field will call not only AutoText but other Building Blocks. Different entries with the same name can lead to problems.
First, the general hierarchy of templates governs. You can add in the Building Blocks and Built-In-Building Blocks templates when dealing with AutoText and Building Blocks. When looking for an AutoText entry named "MyEntry" Word will look:
First in the Attached Template, if the entry is not there, it will look | |
In the Normal.dotm Template; if the entry is not there, it will look | |
In loaded Global Templates; if the entry is not there, it will look | |
In the Built-in Building Blocks Template; if the entry is not there, it will look | |
In the Building Blocks Template. |
I have not yet explored what happens with other templates containing building blocks stored in the Building Blocks folder. Nor have I explored the hierarchy of galleries and categories within a template. I know that if one of the entries is in the AutoText gallery and one is in a different gallery, the AutoText entry will be called. If two entries are both in the AutoText Gallery and they are in different categories, the one created first will be called.
Building Blocks are not available from Templates stored on SharePoint
That is right. They is not. See this thread. This is not my personal experience because I do not use SharePoint. It is based on what I've seen in posts in help forums. This seems to be true of all Building Blocks.
Word does not treat templates stored on SharePoint the same as it does templates stored on the local computer or a network location. If you download the template to your local computer, any Building Blocks can be used (assuming they are loaded as global templates or used as document templates).
If AutoCorrect does something you don't like, immediately press Ctrl+Z to UnDo it. You can edit the AutoCorrect Options to remove entries that consistently cause you problems.
Every Word user should have one of two key AutoCorrect Backup/Restore utilities. The one for Word 97-2003 can be found on the MVP site. The one for later (ribbon) versions (AutoCorrect2007.zip) can be found on Jay Freedman's site. These create a backup Word document that has all of the AutoCorrect entries in a given language in a table. This makes it easy to move entries to a new computer or make changes. Note the utility does not delete AutoCorrect entries that exist. If there is one with the same name, it will replace it. Another backup utility can be found at AutoCorrect Utility Manager.
On one of the Word help forums the question arose on how to deal with multiple AutoCorrect entries that were causing problems. Specifically, the user had AutoCorrects to change the "ise" endings on words to "ize." That is, it would automatically change "customize" to "customise" and so forth. It is likely that this happened from using the spell check option to add spelling errors to AutoCorrect (below). These are not built into Word.
Over time, having this checked is likely to result in a number of entries that are problematic. Going through the list in AutoCorrect Options would be hit-or-miss. The Backup/Restore utility could be used, though, to search the backup document for these entries so that they could later be changed using the AutoCorrect Options. It would also be possible, using that utility, to restore an AutoCorrect without the problem entries. Doing so would require that they be unformatted entries (not stored in the normal template). You could then rename the ACL file with Word closed so Word would not use it. Using the Backup utility would restore all of the other entries without the ones that were deleted.
I would be tempted, though, to simply rename the ACL file and start over from scratch, perhaps looking through the backup file to see if it contains anything very useful.
Running AutoCorrect on Existing or Pasted text (macro required)
AutoCorrect works as you type text. Sometimes, though, you would like to use it on text already typed or text pasted from another source. Here is a macro to do that.
Sub AutoCorrectBruteReplace()
' https://answers.microsoft.com/en-us/msoffice/forum/all/macro-for-autocorrect/91f9bdb1-47ac-4cec-9842-5f1ee38bd7cf?page=1
' rianvillareal 2022-06-11 modified by Charles Kenyon with help by Hans Vogelar to use range and work with selected text
' It is slow. Handles multi-word entries. Does not handle fractions
' It appears to operate only on selected text
'
Dim oEntry As Word.AutoCorrectEntry
Dim oRng As range
Set oRng = Selection.range
For Each oEntry In AutoCorrect.Entries
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = oEntry.Name
.Replacement.Text = oEntry.Value
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
Next oEntry
End SubHere is a second macro for this:
Sub AutoCorrectNow2()
' Graham Mayor Bob Sundquist, Hans Vogelar and Charles Kenyon 2022-06-10
' https://eileenslounge.com/viewtopic.php?f=26&t=38297&p=296123#p296123
' https://www.msofficeforums.com/word-vba/29148-how-replace-wordbasic-autocorrectnow-old-macro.html
' Runs autocorrect on selected text as if it were being retyped - only handles single-word entries
'
'
Dim oWrd As range
Dim Entry As Object
Dim iCount As Long, i As Long
On Error Resume Next
Let iCount = Selection.Words.Count
For i = 1 To iCount
Set oWrd = Selection.Words(i)
For Each Entry In Word.Application.AutoCorrect.Entries
If oWrd.Text = Entry.Name Then
oWrd.Text = Entry.Value
Exit For
ElseIf oWrd.Text = Entry.Name & " " Then
oWrd.Text = Entry.Value & " "
Exit For
End If
Next Entry
Next i
Set oWrd = Nothing
Set Entry = Nothing
End SubInstructions for Installing Macros from Forums or Websites by Graham Mayor, MVP
If you are running AutoCorrect on existing text using a macro, I would recommend doing it on a copy and then using the Compare Documents feature to generate a comparison so you can see the changes that are made and approve/disapprove them. There really is no substitute for human proofreading.
Note that the macros will not insert images and perhaps no formatted AutoCorrect entries. In this Answers thread, MVP Jay Freedman suggests using AutoText for these instead if you are going to need to do this. See my AutoText/Building Blocks macros above.
Checking in vba if an AutoCorrect Entry is already using a name
Private Function AutoCorrectEntryExist(strName As String) As Boolean
' Charles Kenyon 2022-06-14 Reports True if an AutoCorrect Entry uses the name given in strName
' https://stackoverflow.com/questions/72619065/check-if-an-entry-exists-in-autocorrect-entries/72625298#72625298
'
Dim oEntry As Word.AutoCorrectEntry
For Each oEntry In AutoCorrect.Entries
If oEntry.Name = strName Then
MsgBox prompt:=strName & " is already in use, Choose a different name.", _
title:="In Use!", buttons:=vbCritical
AutoCorrectEntryExist = True
GoTo EntryFound
End If
Next oEntry
AutoCorrectEntryExist = False
EntryFound:
Set oEntry = Nothing
End Function
If AutoFormat as You Type causes you problems, immediately press Ctrl+Z to undo the change it made. Then go into the AutoCorrect Options to turn off the feature that is causing you problems. You can see at I keep most of the options off on my computer. Remember that there are two tabs for AutoFormat in the options. You want to make your changes to "Autoformat as You Type."
If you want to save or transfer AutoFormat and AutoFormat as you Type settings, you can record a macro and tab through the tabs of the settings dialog box. Just display each tab of the AutoCorrect settings dialog box and close the dialog and stop recording. The macro will have your settings.
Input |
AutoFormat (Ctrl+Alt+K) |
AutoFormat As You Type |
x-y |
x-y (no change) |
x-y (no change) |
x - y |
x - y (no change) |
x – y (en dash with spaces) |
x--y |
x—y (em dash without spaces) |
x—y (em dash without spaces) |
x -- y |
x—y (em dash without spaces) |
x – y (en dash with spaces) |
Reported by Roger Phillips in the Word Answers forum.
Note that the option for hyphens in both of these also controls conversion of (c) and (r).
Check to see if automatic updating is turned on for the style. With automatic updating, a style is updated automatically when you make additional changes to the style, meaning that every paragraph in your document assigned to that style will change automatically. To turn off this feature, click the Format menu, and choose Style. Select the style in the Styles box, and then click Modify. If the Automatically update check box is selected, clear it.
Your style may have been based on another style that has changed. Changes to a base style affect other styles in the document that are based on it. For example, if you change the font in Normal to the Arial font, Word changes the font for the styles used in footnotes, headers, footers, page numbers, and other text. If you don't want a certain style to change when you change the base style, make certain your style is not based on another style. On the Format menu, click Style. In the Styles box, click the style you want to modify, click Modify, and then click (no style) in the Based on box.
Warning When you base a style on No Style, you
will need to set the Language because the default will be No
Proofing.
(Word 97) Charles Kenyon note: I recommend that you not base any styles on normal and that you change the built-in styles so that they are not based on normal. This is particularly true for any styles that are involved in paragraph numbering. |
Charles Kenyon note: I recommend that you keep the Automatically update styles check box unchecked. Especially if you will be sharing your documents with others, leaving it checked can result in truly bizarre formatting and make your documents ugly or even unusable.
If the template that contains the style definitions is missing or damaged, styles in the current document use the style definitions from the Normal template.
Sometimes when you apply a style that has specific formatting
attributes to text already formatted this way, the reverse formatting may
occur. For example, when you apply a style that contains bold formatting
to a paragraph that contains some bold text, the bold text may lose its
bold formatting. This problem will not occur if you apply character
formatting— either through a character style or direct formatting — after
you apply a paragraph style. Apply the style first, and then select the
words to have other formatting and apply the formatting directly.
Tip To make sure that no direct formatting has been applied to the text, first select the text completely and then press CTRL+SPACEBAR. This removes manually applied formatting. Now when a style is applied, there is no reversing situation to occur. |
Article: http://support.microsoft.com/support/kb/articles/Q176/6/92.ASP
since 14 April 2004
|
Copyright 2000, Microsoft Corporation.
Copyright 2000-2002, 2004-2006, 2010-2024
Charles
Kyle Kenyon
See information about copy permission.
Search Intermediate Users Guide to Microsoft Word Using Google My office page as a Madison, Wisconsin Criminal Defense Lawyer.
Original Legal Users Guide to Microsoft Word 2002 - Documents in Zip Format
A note about link exchanges. This site does not participate in link exchanges to build web presence. If you have a link that you think would be of use to people reading this page, please send it to the webmaster with the url of the page where you think it should appear and it will be considered. Your placing a link to this site will not affect the decision on whether to add your link, though.
|