Cover image for Word Hacks

Book description

As one of the applications in Microsoft Office, Word is the dominant word-processing program for both Windows and Mac users. Millions of people around the globe use it. But many, if not most, of them barely skim the surface of what is possible with Microsoft Word. Seduced by the application's supposed simplicity, they settle for just what's obvious--even if it doesn't satisfy their wants and needs. They may curse the wretched Bullets and Numbering buttons multiple times a day or take hours to change the font size of every heading in a lengthy report, yet they're reluctant to dig deeper to take advantage of Word's immense capabilities and limitless customization tools. Let Word Hacks be your shovel. Let it carve your way into Word and make this most popular and powerful application do precisely what you want it to do. Filled with insider tips, tools, tricks, and hacks, this book will turn you into the power user you always wanted to be. Far beyond a tutorial, Word Hacks assumes you have a solid working knowledge of the application and focuses on showing you exactly how to accomplish your pressing tasks, address your frequent annoyances, and solve even your most complex problems. Author Andrew Savikas examines Word's advanced (and often hidden) features and delivers clever, time-saving hacks on taming document bloat, customization, complex search and replace, Tables of Contents and indexes, importing and exporting files, tables and comments, and even using Google as a dictionary! With him as your guide, you'll soon be understanding--and hacking--Word in ways you never thought possible. Covering Word 2000, 2002 and Word 2003, Word Hacks exposes the inner workings of Word and releases your inner hacker; with it, you will be equipped to take advantage of the application s staggering array of advanced features that were once found only in page layout programs and graphics software and turning Word into your personal productivity powerhouse.

Table of Contents

  1. Word Hacks
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. A Note Regarding Supplemental Files
    3. Credits
      1. About the Author
      2. Contributors
    4. Dedication
    5. Preface
      1. Why Word Hacks?
      2. How to Use This Book
        1. A Note About Word Versions
        2. Where to Learn More
      3. How This Book Is Organized
      4. Conventions Used in This Book
      5. Using Code Examples
      6. How to Contact Us
      7. Got a Hack?
      8. Acknowledgments
    6. 1. Word Under the Hood
      1. Introduction: Hacks #1-2
      2. Hack #1. Tweak the Interface
        1. 1.2.1. Replacing a Toolbar Button
        2. 1.2.2. Modifying a Menu Item
        3. 1.2.3. Activating Important Viewing Options
      3. Hack #2. Macros 101: A Crash Course
        1. 1.3.1. Nuts and Bolts
        2. 1.3.2. Hello, World
        3. 1.3.3. Organizing and Debugging Your Macros
        4. 1.3.4. Running Macros
        5. 1.3.5. Getting Help from the Editor
          1. 1.3.5.1. IntelliSense
          2. 1.3.5.2. The Immediate window
          3. 1.3.5.3. Stepping through code
        6. 1.3.6. Exploring the Word Object Model
    7. 2. The Word Workspace
      1. Introduction: Hacks #3-13
      2. Hack #3. Hack Your Shortcut Menus
        1. 2.2.1. Accessing the Shortcut Menu Toolbar
        2. 2.2.2. Modifying a Shortcut Menu
      3. Hack #4. Create Custom Views
        1. 2.3.1. The Code
        2. 2.3.2. Putting the New View on the View Menu
      4. Hack #5. Revert to Saved
        1. 2.4.1. The Code
        2. 2.4.2. Putting the Macro in Your File Menu
      5. Quickly Change Your File → Open Path
        1. 2.5.1. The Code
        2. 2.5.2. Running the Hack
        3. 2.5.3. See Also
      6. Hack #7. Report and Review Your Options
      7. Hack #8. Force Internet Explorer to Hand Off Word Documents
        1. 2.7.1. Hacking the Hack
      8. Hack #9. Tweak the New Document Task Pane
        1. 2.8.1. Disabling the Task Pane When Word Starts
        2. 2.8.2. Add Documents and Templates to the Task Pane
        3. 2.8.3. The Code
        4. 2.8.4. Hacking the Hack
      9. Hack #10. Browse All Button Images
        1. 2.9.1. Hacking the Hack
      10. Hack #11. Create a Custom Button Image
        1. 2.10.1. The Code
        2. 2.10.2. Hacking the Hack
      11. Hack #12. Hack the Office Assistant
        1. 2.11.1. Banishing the Assistant
        2. 2.11.2. Finding a Sympathetic Character
        3. 2.11.3. Invoking Invisibility
        4. 2.11.4. Getting the User's Attention
        5. 2.11.5. Displaying Information and Presenting Choices
      12. Hack #13. Build a Better MRU
        1. 2.12.1. How Word's MRU Works
        2. 2.12.2. Getting Started
        3. 2.12.3. The Code
          1. 2.12.3.1. Creating the MRU module
          2. 2.12.3.2. Initializing the class module
          3. 2.12.3.3. Displaying the user form
          4. 2.12.3.4. Adding a document's information to the MRU
        4. 2.12.4. Creating the User Form
        5. 2.12.5. Adding the Code to the User Form
          1. 2.12.5.1. Creating the UserForm_Initialize macro
          2. 2.12.5.2. Creating the lstMRU_Click macro
          3. 2.12.5.3. Creating the cmdCancel_Click macro
          4. 2.12.5.4. Creating the cmdOpen_Click macro
        6. 2.12.6. Using the MRU
        7. 2.12.7. Hacking the Hack
    8. 3. Formatting, Printing, and Table Hacks
      1. Introduction: Hacks #14-26
      2. Hack #14. Insert Placeholder Text
        1. 3.2.1. Make Your Own Placeholder Text with AutoCorrect
      3. Hack #15. Sample Your System Fonts
        1. 3.3.1. The Code
        2. 3.3.2. Hacking the Hack
      4. Hack #16. Tab Me to Your Leader
      5. Hack #17. Make Styles More Manageable with Aliases
        1. 3.5.1. Using Aliases in VBA
      6. Hack #18. Make a Simple Bar Graph
      7. Hack #19. Put Footnotes in Tables
      8. Hack #20. Repeat a Section Heading Across Pages
      9. Hack #21. Simplify Borders Around Imported Images
        1. 3.9.1. Hacking the Hack
      10. Hack #22. Make More Flexible Captions
        1. 3.10.1. Automating the Captions
      11. Hack #23. Make PDFs Without Acrobat
        1. 3.11.1. Getting Ghostscript and GSview
        2. 3.11.2. Getting GhostWord
      12. Hack #24. Create a Custom Text Watermark
        1. 3.12.1. The Field Code
      13. Hack #25. Include Only Part of a Heading in a TOC
        1. 3.13.1. Word 2002 and Higher
        2. 3.13.2. Word 2000
      14. Hack #26. Put Crop Marks on a Page
        1. 3.14.1. The Field Code
        2. 3.14.2. Hacking the Hack
    9. 4. Editing Power Tools
      1. Introduction: Hacks #27-44
      2. Hack #27. Crunch Numbers Quickly in Word
        1. 4.2.1. Resurrecting Calculate
        2. 4.2.2. Using Calculate
        3. 4.2.3. Hacking the Hack
      3. Hack #28. Unlink Every Hyperlink
        1. 4.3.1. The Code
        2. 4.3.2. Hacking the Hack
      4. Hack #29. Exclude Text from Find and Replace
      5. Hack #30. Use Character Codes to Find or Insert Special Characters
        1. 4.5.1. Inserting Special Characters
          1. 4.5.1.1. Using ASCII codes
          2. 4.5.1.2. Using Unicode codes
        2. 4.5.2. Searching for Special Characters
          1. 4.5.2.1. Searching with ASCII codes
          2. 4.5.2.2. Searching with Unicode codes
        3. 4.5.3. What's That Character?
      6. Hack #31. Find/Replace in Multiple Files
        1. 4.6.1. The Code
        2. 4.6.2. Hacking the Hack
      7. Hack #32. Find and Replace Without Find and Replace
        1. 4.7.1. The Code
        2. 4.7.2. Running the Hack
        3. 4.7.3. Hacking the Hack
      8. Hack #33. Quickly Create a Custom Dictionary
        1. 4.8.1. Creating the Custom Dictionary
        2. 4.8.2. Activating the Custom Dictionary
      9. Hack #34. Create a Dictionary Exclusion List
      10. Hack #35. Disable Overtype Permanently
      11. Hack #36. Delete All Comments in a Document
        1. 4.11.1. The Code
      12. Hack #37. Delete All Bookmarks in a Document
        1. 4.12.1. The Code
        2. 4.12.2. Hacking the Hack
      13. Hack #38. Turn Comments into Regular Text
        1. 4.13.1. The Code
        2. 4.13.2. Hacking the Hack
        3. 4.13.3. See Also
      14. Hack #39. Apply Context-Sensitive Formatting
        1. 4.14.1. The Code
      15. Hack #40. Send a Document as a Plain-Text Outlook Email
        1. 4.15.1. Setting the Reference to Outlook
        2. 4.15.2. The Code
        3. 4.15.3. Hacking the Hack
      16. Hack #41. Swap Revision Authors
        1. 4.16.1. Hacking the Hack
      17. Hack #42. Corral Basic Bullets and Numbering
        1. 4.17.1. Mapping the Styles to the Buttons
        2. 4.17.2. The Code
        3. 4.17.3. Running the Hack
      18. Hack #43. Cross-Reference Automatically
        1. 4.18.1. Referencing the Way Word Does
        2. 4.18.2. A Better Way to Reference
          1. 4.18.2.1. The supporting procedures
          2. 4.18.2.2. Running the hack
      19. Hack #44. Hack More Flexible Cross-Referencing
        1. 4.19.1. Making the Dialog
        2. 4.19.2. The Code
        3. 4.19.3. Running the Hack
    10. 5. Templates and Outlines
      1. Introduction: Hacks #45-50
      2. Hack #45. Create an Outline-Only Copy of a Document
        1. 5.2.1. The Code
      3. Hack #46. Build a Better Outline
      4. Hack #47. Use an Outline to Build an Org Chart
        1. 5.4.1. The Code
      5. Hack #48. Attach the Same Template to Multiple Files
        1. 5.5.1. The Code
        2. 5.5.2. Hacking the Hack
      6. Hack #49. Quickly Attach a Workgroup Template
        1. 5.6.1. The Code
        2. 5.6.2. Running the Hack
      7. Hack #50. Manage Macros with Templates
        1. 5.7.1. Creating the Global Template
        2. 5.7.2. Adding Macros to the Global Template
    11. 6. Housekeeping
      1. Introduction: Hacks #51-56
      2. Hack #51. Troubleshoot Common Word Problems
        1. 6.2.1. Delete Any Temporary Files
        2. 6.2.2. Start Word with a Clean Slate
        3. 6.2.3. Disable Other Global Templates and COM Add-ins
        4. 6.2.4. Delete the Word Data Key
          1. 6.2.4.1. After you've rebuilt the data key
      3. Hack #52. Control Word Startup
        1. 6.3.1. Startup Switches
          1. 6.3.1.1. Troubleshooting problems
          2. 6.3.1.2. Running further sessions of Word
          3. 6.3.1.3. Opening one or more files
        2. 6.3.2. Hacking the Hack
      4. Hack #53. Sidestep Formatting Restrictions
        1. 6.4.1. Hacking the Hack
      5. Hack #54. Rename Built-in Styles
        1. 6.5.1. Hacking the Hack
      6. Hack #55. Clean Out Linked "Char" Styles
        1. 6.6.1. Spotting Char Styles
        2. 6.6.2. The Code
        3. 6.6.3. Running the Hack
        4. 6.6.4. Hacking the Hack
      7. Hack #56. Reduce Document Bloat by Deleting Old List Templates
        1. 6.7.1. The Code
        2. 6.7.2. Running the Hack
    12. 7. Macro Hacks
      1. Introduction: Hacks #57-69
      2. Hack #57. Get Simple User Input for a Macro
        1. 7.2.1. Hacking the Hack
      3. Hack #58. Keep the Macros Dialog Box Tidy
        1. 7.3.1. Name Macros Clearly and Consistently
        2. 7.3.2. Hide Macros from the Macros Dialog Box
      4. Hack #59. Do Something to Every File in a Directory
        1. 7.4.1. The Code
        2. 7.4.2. Hacking the Hack
      5. Hack #60. Run Macros Automatically
        1. 7.5.1. Disabling AutoMacros
      6. Hack #61. Intercept Word Commands
        1. 7.6.1. Finding the Command's Name
        2. 7.6.2. Command Precedence
        3. 7.6.3. See Also
      7. Hack #62. Keep Custom Menus Under Control
        1. 7.7.1. The Code
      8. Hack #63. Use Word Dialogs in a Macro
        1. 7.8.1. Use Dialogs to Execute Commands Interactively
        2. 7.8.2. Use Dialogs Just to Get Input
      9. Hack #64. Optimize Your VBA Code
        1. 7.9.1. Use Integer Division
        2. 7.9.2. When Possible, Avoid Variants
        3. 7.9.3. Test for Blank Strings with Len
        4. 7.9.4. Assign Objects to Variables
        5. 7.9.5. Don't Skimp on Comments
        6. 7.9.6. Avoid IIf
      10. Hack #65. Show Progress from VBA
        1. 7.10.1. Continuous Progress
        2. 7.10.2. Incremental Progress
      11. Hack #66. Hack Documents with For Each Loops
        1. 7.11.1. When to Avoid For Each Loops
      12. Hack #67. Store Settings and Data in .ini Files
      13. Hack #68. Generate Random Numbers
        1. 7.13.1. Bounded Random Numbers
        2. 7.13.2. n-Digit Random Numbers
        3. 7.13.3. Running the Hack
      14. Hack #69. Hack with Application Events
        1. 7.14.1. Setting Up the Event Handler
        2. 7.14.2. Running the Hack
    13. 8. Forms and Fields
      1. Introduction: Hacks #70-79
      2. Hack #70. Fake (and Easy) Fill-in Forms
      3. Hack #71. Hack DATE Fields
        1. 8.3.1. Display Long Forms of Dates
        2. 8.3.2. Determine a Date's Place in the Year
        3. 8.3.3. Automatically Insert a Past or Future Date
          1. 8.3.3.1. Calculate a month using n months delay
          2. 8.3.3.2. Calculate a month and year using n months delay
          3. 8.3.3.3. Calculate a month and year using n years delay
          4. 8.3.3.4. Calculate a day, date, month, and year using n years delay
          5. 8.3.3.5. Calculate a day, date, month, and year using n months delay
          6. 8.3.3.6. Calculate a day, date, month, and year using n days delay
          7. 8.3.3.7. Calculate a day, date, month, and year using n weeks delay
          8. 8.3.3.8. Internationalizing dates
        4. 8.3.4. Express a Date in Fiscal-Year Terms
        5. 8.3.5. Calculate a Person's Age
        6. 8.3.6. Use Print and Save Information in a Field
      4. Hack #72. Perform Calculations with Formula Fields
        1. 8.4.1. Formula Field Arithmetic Operators
        2. 8.4.2. Formula Field Comparison Operators
        3. 8.4.3. Formula Field Functions
        4. 8.4.4. Formula Field Logical Functions
          1. 8.4.4.1. AND and OR: Testing multiple logical numeric expressions
          2. 8.4.4.2. Testing or returning text strings with logical functions in bookmarks
        5. 8.4.5. Referencing Data in a Table
          1. 8.4.5.1. Referencing cells containing numbers
          2. 8.4.5.2. Reference operators
          3. 8.4.5.3. Referencing an entire row or column
          4. 8.4.5.4. Referencing table cells from outside the table
          5. 8.4.5.5. Referencing row and column totals from outside a table
      5. Hack #73. Format Numeric Field Results
        1. 8.5.1. Compound Picture Switches
      6. Hack #74. Use Fields for Heavy-Duty Calculations
        1. 8.6.1. Logarithms
        2. 8.6.2. Trigonometry
          1. 8.6.2.1. Angle
          2. 8.6.2.2. Sine
          3. 8.6.2.3. Cosine
          4. 8.6.2.4. Tangent
      7. Hack #75. Include an Interactive Calendar in Your Forms
        1. 8.7.1. Hacking the Hack
      8. Hack #76. Use Custom Shortcut Menus to Make Frequent Selections
      9. Hack #77. Number Documents Sequentially
        1. 8.9.1. The Code
      10. Hack #78. Cross-Reference Among Documents
        1. 8.10.1. Understanding Word's Native Cross-Referencing
        2. 8.10.2. Create Cross-References with INCLUDETEXT Fields
      11. Hack #79. Convert Field Codes to Text and Back Again
        1. 8.11.1. Converting Field Codes into Plain Text
        2. 8.11.2. Converting Plain Text into Fields
        3. 8.11.3. Running the Hack
    14. 9. Advanced Word Hacks
      1. Introduction: Hacks #80-89
      2. Hack #80. Emulate Emacs with VBacs
        1. 9.2.1. Installing VBacs
        2. 9.2.2. Using VBacs
      3. Hack #81. Use Word as a Windows Backup Utility
        1. 9.3.1. Running the Hack
        2. 9.3.2. Hacking the Hack
          1. 9.3.2.1. The Parameters section
          2. 9.3.2.2. The Folders section
      4. Hack #82. Perform Power Text Searches with Regular Expressions
        1. 9.4.1. RegExp's Propeties and Methods
        2. 9.4.2. Using the RegExp Object in a Macro
        3. 9.4.3. Performing Replacements
      5. Hack #83. Show a Directory Structure as a Word Outline
        1. 9.5.1. The Code
        2. 9.5.2. Running the Hack
      6. Hack #84. Automate Word from Other Applications
        1. 9.6.1. Controlling Word from Another Office Application
        2. 9.6.2. Controlling Word from a Scripting Language
      7. Hack #85. Hack Word from Python
        1. 9.7.1. Hello, Word
        2. 9.7.2. Controlling Word Interactively
        3. 9.7.3. Running the Hack
          1. 9.7.3.1. Confirming conversions
          2. 9.7.3.2. Word constants
          3. 9.7.3.3. Named arguments
      8. Hack #86. Hack Word from Perl
        1. 9.8.1. Hello, Word
        2. 9.8.2. Running the Hack
          1. 9.8.2.1. Confirming conversions
          2. 9.8.2.2. Word constants
          3. 9.8.2.3. Named arguments
      9. Hack #87. Hack Word from Ruby
        1. 9.9.1. Hello, Word
        2. 9.9.2. Controlling Word Interactively
        3. 9.9.3. Running the Hack
          1. 9.9.3.1. Confirming conversions
          2. 9.9.3.2. Word constants
          3. 9.9.3.3. Named arguments
      10. Hack #88. Use Python from Word
        1. 9.10.1. The Code
        2. 9.10.2. Running the Hack
      11. Hack #89. Use Perl from Word
        1. 9.11.1. Creating COM Objects with the Perl Dev Kit
        2. 9.11.2. Call Perl Directly with the VBA Shell Function
    15. 10. Word 2003 XML Hacks
      1. Introduction: Hacks #90-100
      2. Hack #90. Get a Command-Line XML Processor
      3. Hack #91. Create a Word Document in Notepad
      4. Hack #92. Get the XML Toolbox
      5. Hack #93. Use IE to Inspect WordprocessingML Documents
      6. Hack #94. Transforming XML into a Word Document
        1. 10.6.1. The Code
        2. 10.6.2. Running the Hack
        3. 10.6.3. Hacking the Hack
      7. Hack #95. Batch-Process Word Documents with XSLT
        1. 10.7.1. The Code
        2. 10.7.2. Running the Hack
      8. Hack #96. Standardize Documents with XSLT
        1. 10.8.1. The Code
        2. 10.8.2. Running the Hack
        3. 10.8.3. Hacking the Hack
      9. Hack #97. Remove Direct Formatting with XSLT
        1. 10.9.1. The Code
        2. 10.9.2. Running the Hack
      10. Hack #98. Remove Linked "Char" Styles with XSLT
        1. 10.10.1. The Code
        2. 10.10.2. Running the Hack
        3. 10.10.3. Hacking the Hack
      11. Hack #99. Use Google from Your Macros
        1. 10.11.1. Setting Up the Google Web Service
        2. 10.11.2. Getting a Google API Key
        3. 10.11.3. The Code
        4. 10.11.4. Running the Hack
      12. Hack #100. Google Without Leaving Word
        1. 10.12.1. The Code
        2. 10.12.2. Running the Hack
        3. 10.12.3. Hacking the Hack
    16. Index
    17. Colophon
    18. SPECIAL OFFER: Upgrade this ebook with O’Reilly