Tips.Net > WordTips Home > Macros
The following are additional topics related to the category listed above. A bracketed number after the topic indicates how many articles are related to that subject.
The following articles are available. Click the article's title (shown in bold) to see the associated article.
Adding a Macro to a Toolbar One of the easiest ways to quickly access a macro is to assign it to a toolbar button. How you make the assignment depends on the version of Word you are using. Microsoft Word versions: 97 2000 2002 2003 2007
Adding Smart Quotes through Macro Text When text is added to your document by a macro, and that text includes quotes or apostrophes, Word won’t change the quotes or apostrophes to “smart quotes.” This tip explains why and shows what you can do about this predicament. Microsoft Word versions: 97 2000 2002 2003 2007
Aligning a Paragraph in a Macro If you are applying formatting from within a macro, you may want to change the alignment of various paragraphs. Here’s how you can do it by adjusting the Alignment property. Microsoft Word versions: 97 2000 2002 2003 2007
Assigning a Macro to a Button in Your Text Got a macro you want users to be able to access easily? Just attach that macro to a MACROBUTTON field code, and the trigger for the macro will appear directly within the text of the document itself. This tip explains how to set up such a field in your document. Microsoft Word versions: 97 2000 2002 2003
Assigning a Macro to a Keyboard Combination A quick way to run a macro is to associate a shortcut key combination with the macro, and then use that shortcut to invoke the macro. Assigning shortcuts to macros is easy to do; just follow the steps in this tip. Microsoft Word versions: 97 2000 2002 2003
Assigning a Macro to a Shortcut Key Macros are very powerful. You can make them handy—in addition to powerful—if you assign a shortcut key to your macros. The process is relatively easy, as this tip documents. Microsoft Word versions: 97 2000 2002 2003
Automatically Inserting Brackets Some editorial styles require the use of brackets around words, for instance to indicate which keys on a keyboard should be pressed. If you want a quick way to add brackets around selected text, this tip is for you. Microsoft Word versions: 97 2000 2002 2003
Automatically Inserting Tomorrow's Date Do you routinely need to work with tomorrow’s date? Why not create a template that automatically adds tomorrow’s date to any point in the document you want. This tip shows how easy this can be. Microsoft Word versions: 97 2000 2002 2003 2007
Batch Template Changes Changing the Template on a couple of documents is easy, but what if a whole directory needs to be changed? This VBA macro will do it very quickly. Microsoft Word versions: 97 2000 2002 2003
Calculating a Future Date VBA provides the DateAdd function to perform math on dates. This tip describes how to add and subtract dates to calculate future and past dates. Microsoft Word versions: 97 2000 2002 2003
Changing Between English Variants What is the easiest way to switch between English spelling variants in a document? This tip examines a couple of ways you can handle the desired conversion. Microsoft Word versions: 97 2000 2002 2003
Changing Directories in a Macro When a macro works with files, it often has to change between different directories on your disk drive. This is done using the ChDir command, as described in this tip. Microsoft Word versions: 97 2000 2002 2003 2007
Changing the View in File New Using a Word macro to change the view when selecting New from the File menu. Microsoft Word versions: 97 2000 2002 2003
Checking for a Security Certificate You can digitally sign your VBA projects to help ensure authenticity of your code and increase security. If you use such signatures, it is a good idea if your macros check to ensure that the signature is present. This tip explains how to do the check in VBA. Microsoft Word versions: 2000 2002 2003
Cleaning Up Text in a Macro VBA has a great method for cleaning up the text in a Word document. Microsoft Word versions: 97 2000 2002 2003
Controlling Repagination in Macros For most Word users, repagination of a document is done automatically, in the background, as you are editing. If the edits are being done by a macro, the background repagination may slow down what the macro is doing. If you want to control repagination, you can use the Pagination property or simply turn off screen updating. Microsoft Word versions: 97 2000 2002 2003
Controlling the Bold Text Attribute When processing a document in a macro, you may need to make some of your text bold. It’s easy to do using the Bold attribute, as described in this tip. Microsoft Word versions: 97 2000 2002 2003 2007
Converting Strings to Numbers When creating macros, you often need to convert a text string that contains numbers into actual numeric values. You do this by using the Val function, described in this tip. Microsoft Word versions: 97 2000 2002 2003 2007
Converting Text to Uppercase in a Macro The VBA macro language includes the ability to modify the capitalization of a text selection. There are two ways to perform this conversion, as you discover in this tip. Microsoft Word versions: 97 2000 2002 2003
Counting the Instances of a Text String Sometimes it is helpful to know how often a particular phrase appears within a document. If you need to know such a count, here’s a handy macro you can use to get the desired info. Microsoft Word versions: 97 2000 2002 2003 2007
Creating a Command List Want a list of all the commands available in Word? You can get one easily by following these steps. Microsoft Word versions: 95 97 2000 2002 2003
Creating a Directory Need to create a directory from within a macro? You can do it using a single command line, as detailed in this tip. Microsoft Word versions: 97 2000 2002 2003 2007
Creating a Document Font List If you need a list of fonts used in a document (as opposed to the fonts installed on a system), then the macro in this tip will be of great use. It quickly allows you to pinpoint if you are missing fonts necessary to properly display the document. Microsoft Word versions: 97 2000 2002 2003
Creating a String Need to use a macro to create a text string? One easy way to do it is to use the String function, described in this tip. Microsoft Word versions: 97 2000 2002 2003 2007
Creating or Changing Wizards Wizards are used to programmatically step you through how to create a particular document or create a desired result in Word. You can create your own Wizards or edit existing Wizards if you know the information in this tip. Microsoft Word versions: 97 2000 2002 2003
Determining a Random Value If you need to determine a random value in a macro, you can do so using the Rnd function. This tip presents the syntax and usage of the function. Microsoft Word versions: 97 2000 2002 2003 2007
Determining an Integer Value One of the math functions you can use in your macros is the Int function. It provides a way for you to derive an integer value from whatever original values you are working with. Microsoft Word versions: 97 2000 2002 2003 2007
Determining the Horizontal Position of the Insertion Point Need to figure out how far the insertion point is from the left margin? You can do so by using this small macro that relies on the Information property. Microsoft Word versions: 97 2000 2002 2003 2007
Determining the Length of a String Need to find out in a macro how long a particular text string is? You can figure it out by using the Len function, described in this tip. Microsoft Word versions: 97 2000 2002 2003 2007
Displaying the Document Title Right Away One of the properties that Word maintains for a document is a title. If you want this title displayed on the title bar right after opening the document, you’ll need the single-line macro described in this tip. Microsoft Word versions: 97 2000 2002 2003
Editing Word's Built-in Commands Want to configure Word to do just what you want it to? You can even go so far as to change the actual way in which Word performs its internal commands. This tip explains how you use the VBA editor to change those internal commands. Microsoft Word versions: 97 2000 2002 2003 2007
Extracting INCLUDEPICTURE File Names If you use the INCLUDEPICTURE field to add images to your document, you may love the macro in this tip. It allows you to pull all the filenames used in the field, resulting in a handy image file list. Microsoft Word versions: 97 2000 2002 2003 2007
Finding and Changing Word's Internal Commands How to locate and change one of Word's internal commands. Microsoft Word versions: 6 95 97 2000 2002 2003
Finding Long Lines Tired of paragraphs “spilling over” onto additional lines and ruining your labels? This tip discusses ways you can pinpoint those troublesome paragraphs. Microsoft Word versions: 97 2000 2002 2003
Finding Long Sentences For certain types of writing, you may want to make sure that the sentences in your document do not exceed a certain limit. Word provides no tool to do this, but you can create your own tool for checking sentence length. This tip shows you how. Microsoft Word versions: 97 2000 2002 2003 2007
Getting User Input in a Dialog Box Want to grab some interactive input from a user in your macro? The best way to do that is with the InputBox function, described in this tip. Microsoft Word versions: 97 2000 2002 2003 2007
Highlight Words from a Word List Do you need to highlight certain words in a document, and aren’t quite sure how to go about it? Using the techniques described in this tip, you can create a word list document and then run a macro to highlight all the occurrences of the words in that word list. Microsoft Word versions: 97 2000 2002 2003 2007
How to Paste Non-Floating Pictures with a Macro Using a macro to paste pictures inline instead of floating in Word 97. Microsoft Word versions: 97
Hyperlinks in an Index How to establish a hyperlink between an index and the text in a Word document. Microsoft Word versions: 97 2000 2002 2003
Index Number for the Active Table For some programming needs, it is important to determine the index of an object within a collection of such objects. This tip discusses ways you can determine the index number of a table within the Tables collection. Microsoft Word versions: 97 2000 2002 2003 2007
Inserting a Paragraph from within a Macro Macros are often used to process documents and make changes to them. This quick tip illustrates the macro code to use when you want to place and end-of-paragraph mark within the document. Microsoft Word versions: 97 2000 2002 2003
Inserting Text with a Macro Need to have your macro insert a bit of text into your document? It’s easy to do using the TypeText method. Microsoft Word versions: 97 2000 2002 2003 2007
Intelligible Names for Macros The names you use for macros can affect what you see when you add those macros to a toolbar. This tip explains how you can change macro names on toolbars, as well as change the ToolTip that appears for a macro. Microsoft Word versions: 97 2000 2002 2003
Invisible Macros Where to look for macros that have disappeared from the macro list in Word. Microsoft Word versions: 97 2000 2002 2003
Listing Documents with Passwords Do you need a list of documents that require a password or that require a particular password to open? Word doesn’t provide a way to retrieve such information, but you could do it with a macro. This tip describes the approach that should be used if you decide to develop such a macro. Microsoft Word versions: 97 2000 2002 2003
Macro-Inserted AutoText Doesn't Set Style Inserting AutoText from a macro can give unwanted results, particularly when it comes to any style that may be stored with the AutoText entry. The solution is to make sure your macro uses the RichText parameter, as described in this tip. Microsoft Word versions: 97 2000 2002 2003
Making Macros Run Faster Designing a macro to make it run faster. Microsoft Word versions: 97 2000 2002 2003
Making Macros Run Faster, Take Two A simple way to make your Macros run faster. Part II. Microsoft Word versions: 97 2000 2002 2003
Managing the AutoCorrect List If you need to delete all the entries in your AutoCorrect list, the easiest way to do so is with a macro. This tip describes just such a macro. Microsoft Word versions: 97 2000 2002 2003
Moving the Insertion Point in a Macro One of the common things done in macros is to somehow “process” documents, which often means moving the insertion point in some manner. This tip explains how this is most easily done. Microsoft Word versions: 97 2000 2002 2003 2007
Moving the Insertion Point to the Beginning of a Line If you need to move the insertion point within your macro, then you’ll want to note the HomeKey method, described in this tip. It can be used to move the insertion point to the beginning of a line of text. Microsoft Word versions: 97 2000 2002 2003 2007
Numbers to Text, Take Three (Over a Million) So, you need to convert a number to text that is over one million? Here is a VBA macro that will convert up to 999,999,999. Microsoft Word versions: 97 2000 2002 2003
Occurrences of a Text String within a Document You may have a need to find out how many times a certain text string occurs within a document. You can find out manually using the Find and Replace features of Word, but that won’t work in a macro. The technique in this tip will work, however. Microsoft Word versions: 97 2000 2002 2003 2007
Offering Options in a Macro When creating macros, you often need to offer a series of choices to a user. This tip demonstrates how easy it is to offer options and get feedback, using just a few commands. Microsoft Word versions: 97 2000 2002 2003 2007
Options in Opening Files Changing the standard shortcut for opening a New File. Microsoft Word versions: 97 2000 2002 2003
Passwords for Creating Macros What to do if Word starts asking for a password to create a macro. Microsoft Word versions: 97 2000 2002 2003
Printing and Exiting Word in a Macro When you print a document, Word remains busy in the background until the printing is done. If you try to end the program before printing is done, you can cause problems for your printout. This tip explains how to bypass the potential problem by making just a small change to how the document is printed. Microsoft Word versions: 97 2000 2002 2003 2007
Printing Shortcut Key Assignments from a Macro Adding a line to your Macro to print out your shortcut keys is as easy as one line. Microsoft Word versions: 97 2000 2002 2003 2007
Printing Styles in a Macro Using a Macro to print out a list of styles. Microsoft Word versions: 97 2000 2002 2003 2007
Printing Summary Information from a Macro Word allows you to save document properties with a document. If you want to print those properties under the control of the macro, you need to use the technique described in this tip. Microsoft Word versions: 97 2000 2002 2003 2007
Printing via Macro without Messages When you are printing a document, it is not unusual to see messages (dialog boxes) periodically. When you want the printing to be done by a macro, the messages can cause unwanted interruptions. Here’s a way to make the messages stop. Microsoft Word versions: 97 2000 2002 2003 2007
Problem With Add-on Macros Add-ons for Word normally use macros to perform the tasks for which they were designed. If you suspect that you are having problems with add-on macros in Word, then you may need to apply some of the techniques in this tip to uncover what is going on. Microsoft Word versions: 97 2000 2002 2003
Quickly Dumping Array Contents A VBA macro that will erase all of the information in your array. Microsoft Word versions: 97 2000 2002 2003
Quickly Switching Languages Setting up macros to switch between languages easily. Microsoft Word versions: 6 95 97 2000 2002 2003
Removing a Directory Your macro, in the course of doing some processing, may create a directory that you later need to delete. Here’s how to get rid of it. Microsoft Word versions: 97 2000 2002 2003 2007
Removing All Text Boxes In a Document Got a lot of text boxes you need removed from your document? There are a number of ways you can get rid of them, as this tip explains. Microsoft Word versions: 97 2000 2002 2003
Renaming a File Need to rename a disk file from within a macro? You can do it using the Name command, described in this tip. Microsoft Word versions: 97 2000 2002 2003 2007
Repaginating in a Macro Do you need your macro to repaginate a document? Use the .Repaginate method, as described in this tip. Microsoft Word versions: 97 2000 2002 2003
Repaginating Your Document in a Macro Macros can be used to do extensive processing on a document. After the processing, you may want to repaginate the document. You can do so using the Repaginate method, as described here. Microsoft Word versions: 97 2000 2002 2003
Resetting Character Formatting in a Macro Want your macro to get rid of the formatting applied to a selection of text? It’s easy enough to do using the Reset method, described in this tip. Microsoft Word versions: 97 2000 2002 2003 2007
Reversing a String Need to reverse all the characters in a string? You can do so by using your own function that does the heavy lifting for you. Microsoft Word versions: 97 2000 2002 2003 2007
Running Macros from Macros Need to run one macro from within another macro? You can easily do it by using the Run method of the Application object, as described in this tip. Microsoft Word versions: 97 2000 2002 2003 2007
Safely Relocking Forms In order to use a form in Word, it must be protected. This means that you cannot make any changes to the form, even if you need to. If you unlock the form to make changes, then when you relock it, the data in the form is wiped out. This tip provides a solution you can use to safely relock your forms without losing data. Microsoft Word versions: 97 2000 2002 2003
Searching for Adjectives and Adverbs Searching for different types of words in your documents is a nice thing to contemplate, but it is much harder to do in reality. The English language has enough vagaries that it can be challenging. Microsoft Word versions: 97 2000 2002 2003 2007
Setting a VBA Variable From a Bookmark Bookmarks are a great way to mark a memorable place in a document. When processing a document using macro, you may want to assign some bookmarked text to a variable. This tip explains how to retrieve the desired bookmark information. Microsoft Word versions: 97 2000 2002 2003
Setting the Left Indent of a Paragraph in a Macro Macros are great for processing text in a document. As part of the processing, you may want to modify the formatting of a paragraph. Here’s how to set the left indent of a paragraph within your macro. Microsoft Word versions: 97 2000 2002 2003
Setting the Right Indent of a Paragraph in a Macro Macros can be used to format portions of your document. In order to format the right indent of a paragraph, you use the RightIndent property. This tip explains how to use this property to get just the indent you need. Microsoft Word versions: 97 2000 2002 2003
Suppressing the Control Toolbox Toolbar If the Control Toolbox keeps appearing when you open a document, it can be bothersome. This tip explains why this may happen and what you can do to get rid of the toolbox, once and for all. Microsoft Word versions: 97 2000 2002 2003 2007
Swapping Two Strings Part of developing macros is learning how to use and manipulate variables. This tip examines a technique you can use to exchange the contents of two string variables. Microsoft Word versions: 97 2000 2002 2003 2007
Temporarily Changing the Printer in a Macro If you use a macro to print to a specific printer, that printer becomes the default printer for Word from then on. (Well, at least until you explicitly change the printer.) With the quick technique described in this tip, you can print to any printer you want without the user ever being aware that you had changed from the printer he or she had previously selected. Microsoft Word versions: 97 2000 2002 2003 2007
Toggling Font Assignments in a Macro If you need to quickly switch a text selection from one typeface to another, one way you can do it is with a macro. This tip presents such a macro, along with an alternative method of quickly changing typefaces. Microsoft Word versions: 97 2000 2002 2003 2007
Understanding the While...Wend Structure One of the basic programming structures used in VBA is the While ... Wend structure. This structure helps to make the controlled repeating of programming statements quite easy. Microsoft Word versions: 97 2000 2002 2003 2007
Using AutoCorrect to Start Macros As you are typing, AutoCorrect provides a “check” that what you are entering doesn’t match some pre-defined error triggers. The idea is to make sure your text reflects what you intended to write, rather than what you really wrote. This tip discusses the concept of whether AutoCorrect can be used to not only “fix” what you type, but also start macros that could do even more processing. Microsoft Word versions: 97 2000 2002 2003
Using Mandatory Form Fields Form fields can be used to create specialized forms in Word, which are very handy for collecting information. This tip explains some techniques you can use to ensure that some of your form fields are filled in by the user. Microsoft Word versions: 97 2000 2002 2003
Word's Object Model Understanding Word's Object Model and how it relates to macros in VBA. Microsoft Word versions: 6 95 97 2000 2002 2003
Working With Multiple Printers Using WordBasic Setting up an icon on your toolbar for each Printer you use. Microsoft Word versions: 6 95
The real power behind Word's best documents lies in understanding styles and templates. Learn the key to more powerful document creation. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips