Tips.Net > WordTips Home > Macros > VBA Examples

 

Tips, Tricks, and Answers

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

A Real AutoSave When you enable AutoSave in Word, it doesn’t really save your document; it just saves a temporary file that allows your document to be recovered if the program should end unexpectedly. If you want to really save your document periodically, you need to develop your own macro-based system, as described in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Accessing Paragraphs in a Macro Using the Paragraphs collection, you can quickly access individual paragraphs in a document. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Adding Parentheses Want to add parens around a word or phrase in a single click? Here's a VBA macro that can help you. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Adding Quotes This tip presents a handy little macro that adds quote marks around any selected text. The macro can be assigned to a shortcut key to make adding matching quote marks even faster. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Adjusting Small Caps Text Small caps can be a handy text treatment that makes selected text stand out from the text around it. It is often used for headings within a document. This tip explains how to apply the small caps attribute, and includes a macro that allows you to apply it very quickly. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Aligning Paragraphs in a Macro You can use this VBA code to apply different alignment settings to paragraphs. Microsoft Word versions: 97 | 2000 | 2002 | 2003

An Automatic Two Spaces After a Period Should you put two spaces after a sentence or just one? Ask different people and you will get different answers. To Word the answer isn’t really important; it can help you enforce either type of spacing you want. This tip explains how. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Applying Bold Italics A handy VBA macro that allows you to apply bold and italics attributes with a single click. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Automatic Blank Pages at the End of a Section If you want to have a blank page at the end of a document section, you can insert one manually or you can use the technique described in this tip. The technique makes the added pages dynamic and easy to use. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Automatic Non-breaking Spaces in Dates It drives some people crazy to have a date break across two lines. If you find yourself in this mindset, then you’ll appreciate the ideas presented in this tip for easily making sure that a date stays all on the same line. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Automatically Adding Tabs in Footnotes Word, by default, places a space between a footnote reference character and the actual footnote text. If you want to use a tab instead, you’ll find the information in this tip invaluable. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Automatically Determining a Due Date When you are doing a mail merge in Word, you may need to calculate a date sometime in the future. Word doesn’t include an option to do this, but there are a couple of workarounds you can try. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Automatically Formatting an ASCII File Import a file from a source external to Word, and you can end up with a formatting nightmare. One big step is to remove any extra hard returns in the document. The macro in this tip is very helpful in this regard. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

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 Opening a Document at a Specific Zoom Setting Do you prefer to have your documents open at a specific zoom magnification? You can get whatever magnification you desire by adding one simple macro to your Normal.dot template file. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Automatically Saving Document Copies on Floppy WordPerfect included a command that allowed users to save a copy of their current document to the A: drive. Word has no similar command, but you can create your own that allows you to save document copies to any drive you want. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Automatically Setting Right Leader Tabs If you have a constant need to define tabs at the edge of the right margin, you’ll love the macro-based technique provided in this tip. You can, just by running the macro, set the requisite tab and include either dot or underscore leaders for the tab. 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

Bumping Numbers in a Document A handy VBA macro that automatically increments numbers in names. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Calculated Dates Wanna do date math? Here's how to do it in VBA. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Capitals After Colons Making sure Word capitalizes the first letter after a colon. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Centering a Text Box Different ways you can move a text box to the center of the page. Microsoft Word versions: 95 | 97 | 2000 | 2002 | 2003

Changing Character Color Need to easily change the color of some selected text? A quick way to do it is with a custom macro that sets just the hue that you want. This tip describes such a macro and explains how to modify it for any color desired. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Changing How Go To Works You can force Word's Go To command to start with a cleen slate. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Changing Print Dialog Box Defaults Word doesn’t really remember the settings in the Print dialog box very long. Here’s how to get around that limitation and make the dialog box default to the settings you want. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Changing Text Case If you need to easily change the upper- and lower-case configuration of your text, Word has you covered. All you need to do is use the Change Case feature, as described in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Changing the Default Drive A single line of code is all it takes to change the default drive in your VBA macro. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Changing Toolbar Buttons with VBA Toolbar buttons can have a different appearance depending on their state—whether they have been clicked or not. This tip explains how you can create the two necessary versions of a toolbar button for your customizations. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Character Frequency Count Word collects a wide range of statistics about your documents, but one of the things it doesn’t collect is how many times individual characters appear in the document. (This would be considered a “frequency count” of each character.) You can create a macro to count the characters, but the approach you use to the macro will determine how efficiently the requisite counts are collected. 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

Checking for a Text Selection Length Shows how to figure out if the user made a selection before running the macro. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Clearing the Undo Stack in a Macro Word keeps track of things you can undo. This VBA macro clears the list of things that can be undone. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Combining Documents If you have a quite a few text documents you need to combine into a single Word document, using the menus to do the concatenation can be tedious. This tip explains a couple of ways how you can put the text files together into a larger, single file. Microsoft Word versions: 6 | 95 | 97 | 2000 | 2002 | 2003

Consistent Spacing Do you need to check your document to make sure that each sentence has one and only one trailing space? This tip presents a macro that will make short work of getting rid of any extraneous spaces after sentences. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Continually Saving Normal.dot If your Normal.dot file is continually saved when you exit Word, even when you haven’t made any changes to it, the culprit could be other programs you have operating on your system. This tip explains what you can do to help track down the problem. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Controlling the Italic Text Attribute If you are formatting your document by using a macro, you may need to make some of your text italics. You do that by changing the Italic property for the selection. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Converting Inches to Points Points are a common measurement and often used to specify linear distances in Word. When writing VBA macros, you can use a handy built-in function to quickly convert a measurement in inches into the correct measurement in points. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Converting Lists to Text If you have a numbered list in a document, you might want to convert it to regular, non-dynamic text and not lose the numbers that are in the list. This tip explains a couple of techniques you can use to accomplish the task. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Converting Numbers to Text Converting numbers (123) to text (one hundred twenty-three) is a common requirement in some businesses. This tip provides a macro you can use to handle the conversions for you, with numbers as large as 999,999,999. Microsoft Word versions: 97 | 2000 | 2002 | 2003

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

Copying a File in VBA If your VBA macro needs to make a copy of a file, here's how to do it. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Correct Line Numbers When Printing Selections Line numbers are, for some types of documents, a necessity. Line numbers are usually sequential for a page or for the entire document. If you choose to print just a portion of the page or document, Word actually renumbers the lines on the printed page as if that portion were, in reality, the entire document. If you want the printed page to reflect the line numbers as they would appear if the entire document were printed, the macros in this tip will come in handy. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Counting Characters in a Selection with VBA Need to figure out the number of characters in a range of selected text? Here's how to do it in VBA. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Counting Characters in Text Boxes When you do a word count, the value that is returned does not include any text contained in text boxes. This may not be a significant problem, unless you have a large amount of text in those boxes. This tip discusses ways you can deal with this issue. 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 New Document in VBA You can create a brand new document within your VBA macro. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Default Envelope Margins When you create envelopes in Word, you may want to adjust where the return address and main address are printed. Doing so is not as easy as you might desire, but it can be done. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Deleting a Page Here’s a quick little macro that you can use to dispose of entire pages. Assign it to a button or shortcut, and you have a powerful way to get rid of document pages you no longer need. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Deleting All Comments Got comments in your document? Want to get rid of them all? The easiest way to do so is going to depend on the version of Word you are using and the complexity of the document you are editing. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Deleting All Footnotes Tired of all those footnotes hanging on the bottom of each page in your document? You can get rid of them in one step, as described in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Deriving an Absolute Value Want to know the absolute value of a number? It’s easy to derive in VBA by using the Abs function. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Determining a Paragraph's Style in VBA Use this code if your VBA macro needs the style name applied to a paragraph. 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 Differences Between Dates You can figure out the length between two dates in your VBA macros. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining How Many Styles are Available When writing a macro, you may need to know how many styles are defined in a document. This tip discloses the techniques you can use to figure out just what you need. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining How Many Windows are Open For your VBA macro to work properly, you may need to determine how many document windows are open. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining if a File Exists Your macro may need to know if a particular file exists. This is easy to figure out using the Dir command, and even easier if you use it in the function provided in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Determining if a Text Selection Exists When creating a macro that processes your document text in some way, it is often helpful to determine if there was a text selection made when the macro was run. This is easy enough to do, requiring only a single line of code. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Determining if Caps Lock is On Your VBA macro may need to know if the Caps Lock key is on or not. Here's how to figure it out. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining if Num Lock is On with VBA The NumLock key is used to control the numeric keypad on a PC. If your macro requires that the numeric keypad be enabled or disabled, you need a way to determine the state of the NumLock key. This tip shows how you can implement a simple strategy to determine the condition of the key. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining if Overtype Mode is Active Is your VBA macro running with overtype mode active? This code will let you know. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining If the End of a Text File Has Been Reached When writing a macro that processes a text file, you may need to know when the end of the file has been reached. This is easy to do with the EOF function, described in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Determining Picture Size in VBA A VBA macro that will determine the size of all the graphic objects within your document. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining the Current Directory What directory is the default one? This VBA code returns the information. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining the Current Page Number How to figure out, in a VBA macro, the page number where the selection pointer is located. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining the Day of the Year Need to figure out the day of the year (1 through 366)? This VBA code will do the trick. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining the Hour of the Day Need to figure out the hour of the day (1 through 24)? This VBA code will do the trick. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining the Number of Fonts Available Do you need to figure out how many fonts there are available to your document? Here's the VBA code to do it. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining the Number of Pages in Your Document How to determine the number of document pages within a VBA macro. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining the Number of Paragraphs in a Document Need to know how many paragraphs are in your document? This is very easy to figure out with this VBA code. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining the Size of a File Need to know how many bytes are used by a file? This VBA code will figure it out for you. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Determining Word Frequency How to construct a word frequency list. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Displaying a Message in the Status Bar When creating a VBA macro, place text in the status bar to let people know what is happening. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Filling Table Cells with a Macro Creating tabular data consists of two parts—creating the table and adding the data to the table. If you want to fill a table with data, there are a few macro approaches you can use to do the trick. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Finding a Cell Reference Using TableCellHelper to find a cell reference in your table. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Finding a Lost Menu Bar A few ways to find a missing Menu bar in Word. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Finding a Missing Toolbar A few methods for finding an errant toolbar in Word. Microsoft Word versions: 6 | 95 | 97 | 2000 | 2002 | 2003

Finding an Unknown Character Most of the text in a Word document is readily identifiable because you create it using well-known keystrokes: A, B, C, etc. Some characters are much harder to figure out, however, as they have no keyboard equivalent. If you need to search for or replace these characters, your first task is to figure out what they are. This tip provides an easy way to make that determination so that you can do the desired search or replace operation. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Finding Formatted Bulleted Paragraphs You can use the Bullets tool on the Formatting toolbar to turn paragraphs into a bulleted list. If you want to later search for those bulleted lists, you may be out of luck—Word doesn’t provide an inherent way to perform such a search. The macro in this tip can help you find the lists, however. Microsoft Word versions: 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 Unused Styles Use this VBA macro to determine which styles are being used in the current Word document. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Formatting an ASCII Table with Spaces A VBA macro to format ASCII tables into a Word table with the spaces removed. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Formatting Fractions Need to have a great looking fraction in a document? It’s relatively easy to do if you apply the formatting techniques discussed in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Formatting Text Files with VBA Got a bunch of text that you’ve imported from a text file? Need to make it look better? You can take a stab at it with this macro. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Full Path Names in Word An easy way to display the document's full path name in the title bar. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Getting Input from a Text File VBA includes some commands that you can use to read information from text files (non-Word documents). These commands can come in handy when you need to access a wide variety of information. This tip presents a very simple technique to use these commands and read information from a text file. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Grabbing the MRU List The “MRU” is the most-recently used file list that appears at the bottom of the File menu. Your macros can access the file names on this list by using the techniques described in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Hiding Macros Macros are normally visible in the Macros dialog box, except under very specific circumstances. If you don’t want a macro to be visible, then it is important that you understand those circumstances and how to use them in your own macros. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Importing AutoCorrect Entries The AutoCorrect feature in Word is quite handy, but getting a lot of entries into the feature can be tedious. This tip provides a macro that will allow you to enter entries quite a bit faster. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Including Headers and Footers when Selecting All If you are creating a macro that, in the course of processing your document, needs to update all the fields in the document, you may be surprised to find out the process is more complex than anticipated. This tip explains why this is the case, and provides some code you can use to do the updating you need. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Inserting a Break with a Macro How to insert different types of breaks within a VBA macro. 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

Jumping to the Start or End of a Document Macros often need to jump around in a document in order to complete their processing. If you need your macro to jump to the beginning or end of a document, the task is easy to do if you know the proper programming method to use. This tip shows you exactly how easy it is. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Jumping to the Top of a Page How to move the selection pointer to the top of the current page in a VBA macro. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Marking Multiple Documents After using Word for a while, it is easy to accumulate quite a few documents. At some point you may want to make a change to each of the documents in a folder. This tip explains the basics of how to easily make such a change, without the need to manually open and edit each document. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Merging to Individual Files Mail Merge is great for creating standardized letters that need to go out to a group of people. Each letter ends up as a new section within a much larger document. This tip discusses a way you can store each of those customized letters in their own document, rather than as part of the huge merged document. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Misbehaving Rulers When upgrading from Word 2000 to 2002, many people have a problem with the Ruler function. This tip explains how to fix the issue. Microsoft Word versions: 2002

Moving Found Text Down On a Page When you use the Search feature to find information, if the information is not on the visible page, then Word displays the page with the information and the occurrence of what you are searching for is highlighted on the top row of the window. It is often helpful for it to be on the second or third row, so you can see the context of what was located. This tip explains how you can “move” the page a bit so you can see what was found within its context. 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

Moving Through a Table in a Macro Do you need your VBA macro to step through the contents of a table? Use this technique. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Moving to the Start or End of a Document If you need to move the selection point to the beginning or end of a document, use this VBA code. Microsoft Word versions: 97 | 2000 | 2002 | 2003

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

Numbers to Words Want to spell out your numbers--automatically? This VBA macro presents one way to accomplish the task. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Odd Sorting Sorting information is a common task in Word. Sometimes, however, it is difficult to determine exactly how to sort certain types of information. This tip shows how to use a macro to sort a series of names that may have suffixes associated with them. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Only Showing Readability Statistics Perform a grammar check, and Word displays some statistics that represent an analysis of your words. By writing a macro you can access these statistics and display whatever part of them you want. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Opening the Document Map by Default The Document Map can be a handy tool to use when navigating and working with a large document. If you want the Document Map to always be visible with certain documents, the only way you can ensure this is by using a macro, as detailed in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Picking Up in the Last Document Edited If you work on the same document over and over again, you’ll like the very quick macro in this tip. It loads the last used file and jumps to the location in the document where you last made an edit. Also includes a version of the macro that jumps to the end of the last-used document. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Printer Name on the Status Bar Got multiple printers available to your system? The only way to tell which printer a document will go to is to display the Print dialog box (which means the Print tool is almost worthless). This tip discusses ways you can make printing to different printers easier. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Printing a Bookmark List You can define and use bookmarks to reference all sorts of text and text positions within a document. If, at some point, you want to print a list of the bookmarks you’ve created, you’ll be interested in the macro in this tip. It provides a very simple way to create a list and then print it. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Printing a File List Do you need a quick list of all the files in a particular folder? Here’s a couple of different ways you can get the information you need. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Printing a Font List Do you need to get a list of all the fonts available on your system? It’s easy with the macro included in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Printing All Open Documents Need to print out all the documents you have open? Word doesn’t provide a way to do this, but the macro in this tip will make short work of the task. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Printing Color Separations with VBA When printing in color (at a commercial printer) it is necessary to print different colors of your document in different passes. For this purpose, commercial printers often deal with color separations, or separating a document into its component colors. Word can’t perform such a complex task, but there is a way you can simulate color separations in simple documents. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Printing Copy Numbers Do you need to print numbered copies of a document? A great discussion on how to do this. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Printing Graphic Thumbnails If you use a lot of graphics in your Word documents, then you may want to help manage those graphics by printing small “thumbnails” of all the graphics in a folder. This tip includes a macro that will print thumbnail sheets that are great for just that purpose. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Printing On Both Sides of the Paper A VBA macro to allow duplex printing. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Printing Personalized Copies of a Document Do you need to print individualized copies of documents for a series of individuals? This tip describes how to do just that, without using mail merge. Individual names are pulled from a text file and placed in the header of each document as it is printed. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Printing the Active Document from a Macro Using VBA macros you can process documents in all sorts of ways. One common task you may need to do is to have your macro print the active document. You can accomplish this task by using the PrintOut method, as shown in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Problems Using Words as Bullets If you know the secret, you can use actual words as “bullets” in a bulleted list. The built-in bulleted lists in Word aren’t the way to achieve what you want to do, and this tip explains why. It also provides a macro that you can use to apply the formatting you want to the list. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Protecting Hidden Text How to stop others from seeing your hidden text. Microsoft Word versions: 6 | 95 | 97 | 2000 | 2002 | 2003

Pulling Headers and Footers from Other Files You may have some standard headers and footers you want to make available in your document templates. This tip describes some ways you can approach managing these headers and footers. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Quickly Changing Document Windows Word provides a keyboard shortcut that you can use to cycle through document windows, but no way to do it using the mouse. You can get around this shortcoming by using the macro provided in this tip. 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 Formatting Footers in Documents with Many Sections If you have a document that includes many, many sections, you may want to change each section so that its headers and footers are the same as the section before it. This tip explains how to do the conversion manually, as well as with a very quick little macro. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Quickly Formatting Multiple Documents What is the best way to apply consistent formatting across a range of documents? Templates, of course, are very helpful in this regard. There are other formatting considerations which are not controlled by templates, and this tip presents ways you can account for all the formatting you need to apply. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Removing Extra Paragraph Marks Part of working with other people’s documents is cleaning them up so that they are easier to maintain and format. One common task is removing extra paragraph marks in the document. The macro in this tip makes short work of removing all the extra paragraph marks. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Removing Tabs Used to Indent a Paragraph Someone sends you a document, and it has a lot of tabs in it that are used to indent paragraphs. This tip explains how you can get rid of those tabs as a first step in cleaning up the text. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Removing Unused Styles Got an older document that has a bunch of unused styles defined in it? You can get rid of those styles easily by using the short macro in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Repeating Actions Pressing F4 or Ctrl+Y allows you to repeat the last action you took in Word. If you want to repeat an action more than a single time, you’ll need a macro to do the task. This tip presents a simple one that you can use to repeat an action any number of times. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Replacing Quoted Text with Italics In many documents it is preferable to have special terms formatted as italics when they are first used. Some people, however, often place quote marks around such text. This tip provides a handy macro that can step through a document and make sure that any text surrounded by quote marks is converted to italics text. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Replacing Text in a Macro A handy VBA function that allows you to replace information in the middle of one string with other information. 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

Reverse Numbered Lists Numbered lists are easy to generate in Word; it is part of the built-in formatting capabilities of the program. If you want reverse numbered lists (lists that count down toward 1), then you need to create your own lists that are a bit more tricky in nature. This tip explains how to get just what you want. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Reversing Type How to make type appear white on a black background. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Saving a Document in a Macro After processing a document in a VBA macro, you probably need to save it. Here's how. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Saving Everything Do you want Word to save all documents that users create, regardless of whether they choose to save them or not? This configuration involves the use of a couple of macros and an intrinsic change to the way that Word does its work. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Saving Information in a Non-Document Text File When using macros, you aren’t limited to storing information in a document. A full set of commands are available that allow you to open text files and store information in them, as well. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Screen Flip Flop with VBA A handy VBA macro that switches which of two document windows is displayed on top. 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

Searching for Borders The Find and Replace feature in Word allows you to easily search for lots of different items or characteristics in your document. One of the things you cannot natively do, however, is to search for borders on paragraphs. This tip introduces two macros that make short work of finding any bordered paragraphs in your documents. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Searching for Floating Graphics Graphics can be added to a document so that they are either inline with the text or floating over the text. You can use Word’s find and replace tool to locate the inline graphics, but not the floating ones. This tip provides ways you can find the latter. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Select All Changes By a Particular Reviewer If you are using Word 2002 or Word 2003, and you’ve been tracking changes in a document, you can display all the changes made by individual editors. This tip shows how easy such a task can be. Microsoft Word versions: 2002 | 2003

Selecting a Bookmark in a Macro If you want to select the text represented by a macro, here's how to do it in VBA. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Selective Formatting in Replacements Do you need to replace text with a term or phrase that uses multiple formats? You can perform this seemingly complex task using the powerful find and replace tools in Word, or you can create a macro that will do the trick for you. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Setting a Default Table Border Width Specifying the border to be used by default for tables. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Setting Change Bars Manually A couple of ways you can add change bars to your document. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Setting Decimal Tabs in a Table Using the Keyboard Most people use the mouse to set tab stops in the paragraphs in a table. If you prefer to not use the mouse, then you’ll be interested in the techniques for keyboard tab setting, as described in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Setting Maximum Line Lengths in Word E-mail Messages When you use Word as your e-mail editor, it allows you to format the text of your e-mail messages using tools you are familiar with. One thing that is harder to do, however, is to limit the line length of e-mail messages created with Word. This tip explains why the difficulty arises and what you can do to work through the difficulty. 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

Sharing Headings with Others The headings in your document are very important. The constitute the outline of what your document conveys. If you want to share those headings with others (without sharing the document itself), you’ll love the information in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Single Instance of Word Here's a nifty macro that allows you to limit how many instances of Word 97 are open at the same time. Microsoft Word versions: 97

Single-Character Fractions When typing in Word, some fractions are converted into a professional-looking character, while others are not. This tip explains why that occurs and provides some ideas on how all your fractions can look their best. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Spacing After Sentences Word can check to see if you have a consistent number of spaces at the end of your sentences. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Specific Capitalization How to get around Word's AutoCorrect feature for having uncapitalized words at the start of a sentence. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Specifying a Paper Tray in a Macro If your printer uses multiple paper trays, you may want a way to access those trays from a macro. Why? Because you may want the macro to print a part of your document on a particular paper that you have in that tray. This tip describes how you can accomplish the task and explains all the caveats related to the process. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Strip Trailing Spaces A common nuisance in documents is unnecessary trailing spaces at the end of paragraphs. This tip provides a macro that makes quick work of those spaces, removing them from the document completely. 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

Talking to Yourself Using Hidden Text Got a few notes you want to add to a document? You can do it with comments, but another way may be better: Add notes that won’t print out, right in the regular text. This tip explains how that is done and even provides a macro that makes it easier. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Templates and Page Setup Templates are a great way to share styles, macros, and other settings among various documents. One thing that isn’t shared through templates, however, is page setup. If you want to have this shared, you’ll love the macro presented in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

The Case of the Vanished Menu Bar Has your Word menu bar disappeared? This tip explains how you can restore the menu bar to its rightful place at the top of your screen. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Tiling Documents A quick method of placing your open documents side by side on the screen. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Toggling AutoCorrect Settings If you need to turn AutoCorrect on or off, there is no built-in way to easily do it in Word. You can create your own toggle command, however, as described in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Transposing Two Paragraphs There is no command in Word to transpose (switch the position of) two paragraphs. Such a command would be a real boon for some editing tasks, and it can be easily implemented by using the macro in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Trimming Spaces from Strings An overview of the three trimming statements available in VBA. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Turning Off Default First Page Numbering How to set up Word so the First Page Numbering default is not selected. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Turning Off Screen Updating Speed up your VBA macros by turning off updates of the screen. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Underlining Quoted Text Do you have a document in which you need to convert all the quoted text (text surrounded by quotes) to underlined text? If so, then the macro presented in this tip will be a huge timesaver for you. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Understanding Document Variables VBA allows you to create document variables that are persistent. Here's how to do so. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Understanding the For ... Next Structure One of the common programming structures used in macros is the For … Next structure. It allows a block of programming code to be repeated a specific number of times. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Understanding the If ... End If Structure The VBA programming language includes several programming structures that can modify the way in which programming statements are executed. This tip explains one of those structures and how it allows you to place conditions on when certain parts of your macro are executed. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Understanding the Select Case Structure One very helpful programming construct is the Select Case structure. It allows you to set up a series of “triggers” that will execute different blocks of programming code. This tip explains how you can use a Select Case structure in your own macro programming. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Updating Calculated Fields in a Form Using a macro to determine if the Calculated Fields in your document calculate correctly. Microsoft Word versions: 6 | 95 | 97 | 2000 | 2002 | 2003

Updating Fields in Locked Forms If you create a form in Word and then lock it, you may notice that regular fields don’t get updated in the locked document as you might expect. If you want to update the fields, you must first unlock the document. This tip provides a quick macro you can use that will unlock, update, and relock the form—quite a timesaver! Microsoft Word versions: 97 | 2000 | 2002 | 2003

Using a Macro to Change the Formatting of All Instances of a Word If you use the formatting of a specific word as a design element in your document, you may be interested in the macro in this tip. It allows you to format all occurrences of a word in a desired manner. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Viewing Side-by-Side Pages How to display pages side-by-side, through a VBA macro. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Working With Multiple Printers Using VBA Some Word users are fortunate enough to have access to multiple printers. This tip provides a quick way you can access those printers through a custom macro that bypasses the need to use the Print dialog box. Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007

Zooming With the Keyboard With computer screens getting larger, video resolutions getting higher, and eyeballs getting older, the zoom feature is a great tool to learn to use. Unfortunately, Word doesn't provide a quick way to access the zoom feature strictly using the keyboard. You can remedy that shortcoming with the macros discussed in this tip. Microsoft Word versions: 97 | 2000 | 2002 | 2003

Helpful Links

Ask a Word Question
Make a Comment

Tips.Net Home
Vital News Home

WordTips FAQ
WordTips Premium

Learn Access Now

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Pet Tips
Word2007 Tips
WordTips

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)