Tips.Net > WordTips Home > Macros

 

More Topics

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.

Tips, Tricks, and Answers

The following articles are available. Click the article's title (shown in bold) to see the associated article.

Adding a Macro to a Toolbar Word's customization abilities will allow a macro to be placed on a toolbar. Microsoft Word versions: 97 | 2000 | 2002 | 2003

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

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 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

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

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 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 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 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

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

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

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 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

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

Helpful Links

Ask a Word Question
Make a Comment

WordTips
Word 2007 Tips
ExcelTips
Excel 2007 Tips
Vital News Home
 
WordTips FAQ
WordTips Premium
 
Learn Access Now
 
Beauty Tips
Car Care Tips
Cleaning Tips
College Tips
Cooking Tips
Gardening Tips
Health Tips
Home Improvement
Money Tips
Pet Tips
Tips.Net Home
 
Advertise on the
WordTips Site

 

Great Info!

Get tips like this every week in WordTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)

RSS Feeds

RSS 2.0 Daily Nuggets (a WordTip every day)

RSS 2.0 Allen Wyatt's WordTips (the weekly classic)