O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  


 
Buy the book!
Word Hacks
By Andrew Savikas
November 2004
More Info

How do these hacks stand up? Comment on a hack from the book by choosing the associated "Discuss" link below. You can also view the code from any of the hacks by clicking on the "Listing" or "Code" links. A number of hacks have been selected to be featured online in their entirety; you may view those hacks by clicking on the hack titles that are linked.

You can also download all the scripts and other files for this book here.

Jump to: Word Under the Hood  | The Word Workspace  | Formatting, Printing, and Table Hacks  | Editing Power Tools  | Templates and Outlines  | Housekeeping  | Macro Hacks  | Forms and Fields  | Advanced Word Hacks  | Word 2003 XML Hacks

Word Under the Hood

HACK
#1

Tweak the Interface
Take charge of toolbars, menus, and screen real estate with a few trips to the Tools menu
[Discuss (0) | Link to this hack]

HACK
#2

Macros 101: A Crash Course
This hack offers a whirlwind tour of macros, which can help you automate tedious and time-consuming tasks
[Discuss (0) | Link to this hack]

The Word Workspace

HACK
#3

Hack Your Shortcut Menus
To find relevant commands quickly, most Word users head straight for the shortcut menus. But like any Word menu, a shortcut menu is yours for the hacking
[Discuss (1) | Link to this hack]

HACK
#4

Create Custom Views
You can easily get a bit disoriented as you change views, toolbars, and zoom levels within Word. This hack shows how to create predefined views and return to them instantly
The Code
[Discuss (0) | Link to this hack]

HACK
#5

Revert to Saved
Most other word processors and layout programs put a Revert to Saved command right on the File menu. This allows for a quick return to the last saved version of a file. This hack shows you how to add this feature in Word
The Code
[Discuss (0) | Link to this hack]

HACK
#7

Report and Review Your Options
A freeware template from MouseTrax displays all of your Word Options settings in a convenient report format
[Discuss (0) | Link to this hack]

HACK
#8

Force Internet Explorer to Hand Off Word Documents
Trying to edit a Word document from a browser window is like typing with mittens on. This hack shows you how to stop Word documents from opening in Internet Explorer
[Discuss (0) | Link to this hack]

HACK
#9

Tweak the New Document Task Pane
The jury's still out on the Task Pane introduced in Word 2002, and poor documentation along with bad behavior has only hurt its case. This hack offers some tips on taming the worst offender: the New Document pane
The Code
[Discuss (1) | Link to this hack]

HACK
#10

Browse All Button Images
When you start adding buttons or menus to a document or template, it would be nice to have more than a few button images to choose from. This hack shows you how to browse all the button images available on your system
[Discuss (0) | Link to this hack]

HACK
#11

Create a Custom Button Image
Customize your controls with any image you can bitmap—even a favorite photo
The Code
[Discuss (0) | Link to this hack]

HACK
#12

Hack the Office Assistant
Keep Clippit—Microsoft's annoying computer help character—on a short leash with the techniques shown in this hack
[Discuss (0) | Link to this hack]

HACK
#13

Build a Better MRU
Summon more than your nine most recently used files at the touch of a button with this hack
The Code
[Discuss (0) | Link to this hack]

Formatting, Printing, and Table Hacks

HACK
#14

Insert Placeholder Text
When designing a template or experimenting with formatting, sometimes you just need text—any text—to play around with
[Discuss (0) | Link to this hack]

HACK
#15

Sample Your System Fonts
Your system probably offers more than 100 fonts. How do you choose the right one? If you rely on simple trial and error, you'll quickly find yourself frustrated. Instead, use this hack to get a sample of every available font
The Code
[Discuss (0) | Link to this hack]

HACK
#16

Tab Me to Your Leader
Tables have superseded tab stops, which have largely gone the way of the IBM Selectric typewriter. However, tabs are still the best tool for the job when working with leaders. This hack offers some tips for taming those tabs
[Discuss (0) | Link to this hack]

HACK
#17

Make Styles More Manageable with Aliases
Assigning short nicknames to styles can really speed up your formatting time
[Discuss (0) | Link to this hack]

HACK
#18

Make a Simple Bar Graph
Simple graphics can really spice up a document. This hack shows you how to create a bar graph by fiddling with some table formatting
[Discuss (0) | Link to this hack]

HACK
#19

Put Footnotes in Tables
This hack shows you how to implement this sorely needed feature in a table
[Discuss (0) | Link to this hack]

HACK
#20

Repeat a Section Heading Across Pages
Instructions or examples in a document can span multiple pages. This hack shows you how to help your readers follow along by repeating the heading on each page
[Discuss (0) | Link to this hack]

HACK
#21

Simplify Borders Around Imported Images
For a clean, professional look, the borders around imported images in a document should be attractive and consistent. If you create a paragraph style especially for "holding" your images, your image borders will look better and be easier to adjust if needed
[Discuss (0) | Link to this hack]

HACK
#22

Make More Flexible Captions
Word offers a built-in captions feature, but it allows you to use a heading style only for the chapter number. This hack shows you how to expand your options
[Discuss (0) | Link to this hack]

HACK
#23

Make PDFs Without Acrobat
PDF has become a nearly universal file format for displaying documents. But while you can download Adobe Reader for free, you must shell out nearly $300 for the full version if you want to create PDFs. Fortunately, you can use the free Ghostscript and GhostWord programs to create PDFs instead
[Discuss (0) | Link to this hack]

HACK
#24

Create a Custom Text Watermark
Instead of using Word's predefined options, you can create your own watermark text with a few lines of PostScript slipped inside your document
[Discuss (0) | Link to this hack]

HACK
#25

Include Only Part of a Heading in a TOC
Give your headings more flexibility while keeping the table of contents (TOC) under control
[Discuss (0) | Link to this hack]

HACK
#26

Put Crop Marks on a Page
Commercial print shops usually require crop marks for custom-sized print pieces. This hack shows you how to include these important guides in a Word document
[Discuss (1) | Link to this hack]

Editing Power Tools

HACK
#27

Crunch Numbers Quickly in Word
Sometimes a spreadsheet is overkill. For quick and dirty math, dust off one of Word's oldest commands: Calculate
[Discuss (0) | Link to this hack]

HACK
#28

Unlink Every Hyperlink
Sometimes uninvited, often distracting, and always hard to wrangle, hyperlinks tend to stick around your documents like unwelcome guests at a party. Here's how to show them the door
The Code
[Discuss (0) | Link to this hack]

HACK
#29

Exclude Text from Find and Replace
This hack turns "Find what" into "Find not what.
[Discuss (0) | Link to this hack]

HACK
#30

Use Character Codes to Find or Insert Special Characters
It's easy to find common characters on the keyboard. But when you need to find or create an uncommon character, using character codes can make things much easier
[Discuss (2) | Link to this hack]

HACK
#31

Find/Replace in Multiple Files
Make the same substitution on several files at once using the code in this hack
The Code
[Discuss (0) | Link to this hack]

HACK
#32

Find and Replace Without Find and Replace
This brute-force hack lets you power through simple substitutions without complicated code
The Code
[Discuss (2) | Link to this hack]

HACK
#33

Quickly Create a Custom Dictionary
Adding items to a custom dictionary one by one is a tedious exercise. Here's how to add an entire list of words to your existing custom dictionary, or as a separate, new custom dictionary
[Discuss (0) | Link to this hack]

HACK
#34

Create a Dictionary Exclusion List
You can't remove words from any of Word's built-in dictionaries, but you can create a list of words that the Spelling and Grammar check will always flag
[Discuss (0) | Link to this hack]

HACK
#35

Disable Overtype Permanently
Inspiration strikes, and you begin a flurry of typing with nary a glance at the screen. A few minutes later, you look up and discover with horror that you've accidentally entered Overtype mode, that zero-sum game of editing by attrition. This hack shows you how to disable Overtype mode once and for all
[Discuss (0) | Link to this hack]

HACK
#36

Delete All Comments in a Document
Word 2002 and 2003 include a command on the Reviewing toolbar that deletes all the comments in a document. For users of earlier versions of Word, this hack does the same thing
The Code
[Discuss (0) | Link to this hack]

HACK
#37

Delete All Bookmarks in a Document
Word offers no built-in way to delete all of a document's bookmarks at once. This hack shows you how to do it with some VBA
The Code
[Discuss (0) | Link to this hack]

HACK
#38

Turn Comments into Regular Text
This hack shows you how to replace a comment's reference with its text and author
The Code
[Discuss (0) | Link to this hack]

HACK
#39

Apply Context-Sensitive Formatting
Which character style you apply to a selection of text may depend on its context. This hack makes it easy to apply the correct one of several similar styles by using a macro to examine the selection's surroundings
The Code
[Discuss (0) | Link to this hack]

HACK
#40

Send a Document as a Plain-Text Outlook Email
Use a macro to turn the text of a Word document into the body of an Outlook email
The Code
[Discuss (0) | Link to this hack]

HACK
#41

Swap Revision Authors
This hack shows you how to edit the information Word stores when you edit a document using the Track Changes feature
[Discuss (0) | Link to this hack]

HACK
#42

Corral Basic Bullets and Numbering
Word offers 10 reliable, customizable, and, best of all, predictable built-in styles for making bulleted and numbered lists. So how come they've got nothing to do with those decidedly list buttons on the toolbar? Here's how to hack some more helpful buttons
The Code
[Discuss (1) | Link to this hack]

HACK
#43

Cross-Reference Automatically
Using the Cross-reference dialog to insert references, particularly in a lengthy document, can be frustrating because it shows you only a few headings at a time. This hack shows you how to create references automatically, without a visit to the dialog
[Discuss (0) | Link to this hack]

HACK
#44

Hack More Flexible Cross-Referencing
Word's cross-referencing feature locks you into a box of predetermined possibilities. This hack shows you how to build a better box
The Code
[Discuss (0) | Link to this hack]

Templates and Outlines

HACK
#45

Create an Outline-Only Copy of a Document
This hack shows you how to quickly extract just the outline from a document
The Code
[Discuss (0) | Link to this hack]

HACK
#46

Build a Better Outline
Many Word users are at least aware of Outline view, and many use it to help structure lengthy documents. But when the outline the document, few take advantage of the features Outline view has to offer
[Discuss (0) | Link to this hack]

HACK
#47

Use an Outline to Build an Org Chart
Word's outlining feature excels at managing hierarchical information. This hack shows you how to use an outline to create an organizational chart on the fly
The Code
[Discuss (0) | Link to this hack]

HACK
#48

Attach the Same Template to Multiple Files
Use a macro to update or change the template for all the files in a folder
The Code
[Discuss (0) | Link to this hack]

HACK
#49

Quickly Attach a Workgroup Template
It's a rare corporate Word user who knows offhand the location of her Workgroup templates on the network. Word knows where they are, but try attaching one to an existing document, and you get a pop quiz on the subject! Reeducate Word with this hack
The Code
[Discuss (0) | Link to this hack]

HACK
#50

Manage Macros with Templates
By default, Word stores macros in the ubiquitous Normal template. This works fine in the short term, but macros you plan to keep and reuse should go in a separate template
[Discuss (0) | Link to this hack]

Housekeeping

HACK
#51

Troubleshoot Common Word Problems
This hack offers a systematic approach to fixing common frustrations
[Discuss (0) | Link to this hack]

HACK
#52

Control Word Startup
This hack lets you start Word with your favorite template or macro. It also shows you how to open Word with a recent or specific document, suppress the Word splash screen, and do away with the wretched default blank document
[Discuss (0) | Link to this hack]

HACK
#53

Sidestep Formatting Restrictions
Formatting protection can help keep documents rigidly consistent, but sometimes you gotta break the rules
[Discuss (0) | Link to this hack]

HACK
#54

Rename Built-in Styles
Word is often merely the input phase in a production line that ends with a more formidable layout package, such as Adobe InDesign or QuarkXPress. This hack shows you how to make Word documents more palatable to other programs
[Discuss (0) | Link to this hack]

HACK
#55

Clean Out Linked "Char" Styles
Documents created or edited in Word 2002 or 2003 have a nasty habit of sprouting hidden character styles that are hard to see, let alone eliminate. This hack shows you how to lead a "Char-free" life with Word
The Code
[Discuss (2) | Link to this hack]

HACK
#56

Reduce Document Bloat by Deleting Old List Templates
Long documents and documents that have been heavily edited can become needlessly bloated by the remnants of lists long since deleted from the text. This hack shows how to clean out this cruft
The Code
[Discuss (0) | Link to this hack]

Macro Hacks

HACK
#57

Get Simple User Input for a Macro
Macros that interact with the user can be very useful. This hack shows you how to get feedback from a user without the overhead or complexity of a VBA UserForm
[Discuss (0) | Link to this hack]

HACK
#58

Keep the Macros Dialog Box Tidy
Reduce clutter in your Macros dialog box by preventing it from displaying some of your macros
[Discuss (0) | Link to this hack]

HACK
#59

Do Something to Every File in a Directory
Even the simplest Word task becomes arduous when it must be repeated more than a handful of times. Give your mouse a rest, and let Word do the work with this hack
The Code
[Discuss (0) | Link to this hack]

HACK
#60

Run Macros Automatically
Macros are all about automation, but to run they typically require you to click a toolbar button or select a menu item. This hack shows you how to create macros with minds of their own that run whenever you create, open, or close certain templates or documents
[Discuss (0) | Link to this hack]

HACK
#61

Intercept Word Commands
This hack shows you how to change the way Word works with the ominous-sounding technique of command interception
[Discuss (0) | Link to this hack]

HACK
#62

Keep Custom Menus Under Control
This hack reveals how to make sure macros that create custom menu items clean up after themselves
The Code
[Discuss (0) | Link to this hack]

HACK
#63

Use Word Dialogs in a Macro
Using Word's own dialogs in your macros allows the person using the macros to work with a familiar interface, which can make even complicated macros seem easy to use
[Discuss (0) | Link to this hack]

HACK
#64

Optimize Your VBA Code
As you create more complex macros, minor delays caused by poor coding can really add up. This hack will help your VBA code run faster
[Discuss (0) | Link to this hack]

HACK
#65

Show Progress from VBA
When macros take a long time to run, people get nervous. Did it crash? How much longer will it take? Do I have time to run to the bathroom? Relax. This hack shows you two ways to create a macro progress bar using VBA
[Discuss (0) | Link to this hack]

HACK
#66

Hack Documents with For Each Loops
When you need a quick and dirty solution, you don't always have time to find the best tool for the job. This hack introduces you to the Swiss Army Knife of VBA programming
[Discuss (0) | Link to this hack]

HACK
#67

Store Settings and Data in .ini Files
VBA includes a way to store and retrieve information using plain-text files that are easy to create, easy to edit, and easy to remove
[Discuss (0) | Link to this hack]

HACK
#68

Generate Random Numbers
Randomization is an esoteric area of most programming languages, and VBA's no exception. This hack gives you easy access to two of its most common forms
[Discuss (0) | Link to this hack]

HACK
#69

Hack with Application Events
Application events offer a powerful way to run VBA code when certain things happen within Word
[Discuss (0) | Link to this hack]

Forms and Fields

HACK
#70

Fake (and Easy) Fill-in Forms
This hack shows you how to quickly create "click-to-replace" text in any document
[Discuss (0) | Link to this hack]

HACK
#71

Hack DATE Fields
Perform advanced date calculations with this grab bag of field hacks
[Discuss (0) | Link to this hack]

HACK
#72

Perform Calculations with Formula Fields
You can do a surprising amount of number crunching without resorting to an Excel spreadsheet. This hack introduces you to Word's formula fields
[Discuss (0) | Link to this hack]

HACK
#73

Format Numeric Field Results
How you display the result of a calculation can be almost as important as the result itself. This hack shows you how to get field results into the format you need
[Discuss (0) | Link to this hack]

HACK
#74

Use Fields for Heavy-Duty Calculations
By combining several types of Word fields, you can perform some surprisingly complex calculations
[Discuss (0) | Link to this hack]

HACK
#75

Include an Interactive Calendar in Your Forms
This hack shows you how to implement an easy-to-use calendar for choosing dates from within a form or other document
[Discuss (0) | Link to this hack]

HACK
#76

Use Custom Shortcut Menus to Make Frequent Selections
Use an AUTOTEXTLIST field to create a drop-down list you can right-click at any spot in a document
[Discuss (0) | Link to this hack]

HACK
#77

Number Documents Sequentially
Many businesses use numbers to track forms such as invoices and purchase orders. Those numbers usually must go in order and can't repeat. This hack shows you how to use Word to keep track of the numbering for you
The Code
[Discuss (0) | Link to this hack]

HACK
#78

Cross-Reference Among Documents
This hack shows you how to create cross-references among different Word documents
[Discuss (0) | Link to this hack]

HACK
#79

Convert Field Codes to Text and Back Again
When experimenting with fields, or using example fields culled from the Internet, it's often helpful to have an easy way to convert field codes to plain text, and vice versa
[Discuss (2) | Link to this hack]

Advanced Word Hacks

HACK
#80

Emulate Emacs with VBacs
You've already learned all those Emacs commands, so you might as well use them. This set of freeware macros replicates many common Emacs keyboard shortcuts within Word
[Discuss (0) | Link to this hack]

HACK
#81

Use Word as a Windows Backup Utility
This hack introduces a freeware, hackable Word template for building system backups
[Discuss (0) | Link to this hack]

HACK
#82

Perform Power Text Searches with Regular Expressions
When wildcards just aren't enough, tap VBScript for powerful string searching in Word
[Discuss (0) | Link to this hack]

HACK
#83

Show a Directory Structure as a Word Outline
Use Outline view to quickly scan a directory for errant files or space hogs with this RTF hack
The Code
[Discuss (0) | Link to this hack]

HACK
#84

Automate Word from Other Applications
Many of the same things VBA makes possible from within Word can be done from another application by using COM automation
[Discuss (0) | Link to this hack]

HACK
#85

Hack Word from Python
Use Word from Python to create attractive printouts of HTML documents on the fly
[Discuss (0) | Link to this hack]

HACK
#86

Hack Word from Perl
Use Word from Perl to create attractive printouts of HTML documents on the fly
[Discuss (0) | Link to this hack]

HACK
#87

Hack Word from Ruby
Use Word from Ruby to create attractive printouts of HTML documents on the fly
[Discuss (0) | Link to this hack]

HACK
#88

Use Python from Word
This hack shows you how to create standalone Python objects that you can run from within Word using VBA
The Code
[Discuss (0) | Link to this hack]

HACK
#89

Use Perl from Word
This hack shows you two very different ways of getting at Perl from within a Word macro
[Discuss (0) | Link to this hack]

Word 2003 XML Hacks

HACK
#90

Get a Command-Line XML Processor
Here's a rundown of the tools you'll need to work with the Word XML shown throughout this chapter
[Discuss (0) | Link to this hack]

HACK
#91

Create a Word Document in Notepad
This hack demonstrates how you can use simple XML files to create Word documents
[Discuss (0) | Link to this hack]

HACK
#92

Get the XML Toolbox
This free add-in from Microsoft lets you inspect the XML in a Word document while the document remains open, making it an essential tool for working with XML in Word
[Discuss (0) | Link to this hack]

HACK
#93

Use IE to Inspect WordprocessingML Documents
Internet Explorer is a great tool for reading WordprocessingML files, but without a little hacking, it's hard to keep Word's hands off those files
[Discuss (0) | Link to this hack]

HACK
#94

Transforming XML into a Word Document
With the right XSLT stylesheet, you can quickly transform an XML document into a Word document
The Code
[Discuss (0) | Link to this hack]

HACK
#95

Batch-Process Word Documents with XSLT
This hack shows you how to use XSLT to compile a report containing information from several different WordprocessingML documents
The Code
[Discuss (0) | Link to this hack]

HACK
#96

Standardize Documents with XSLT
Before you print or distribute a document, you'll often want to put it into a consistent format without any extraneous items, such as comments left over from editing. This hack shows you how to use XSLT to scrub a document clean
The Code
[Discuss (0) | Link to this hack]

HACK
#97

Remove Direct Formatting with XSLT
Strip out non-style-based formatting from Word documents
The Code
[Discuss (0) | Link to this hack]

HACK
#98

Remove Linked "Char" Styles with XSLT
This hack shows you how to clean out the hidden, linked character styles Word likes to spontaneously create with a dose of XSLT
The Code
[Discuss (4) | Link to this hack]

HACK
#99

Use Google from Your Macros
This hack shows you how to access Google from your Word macros
The Code
[Discuss (0) | Link to this hack]

HACK
#100

Google Without Leaving Word
This hack shows you how to search Google from within Word and display the results on the Task Pane
The Code
[Discuss (0) | Link to this hack]


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.