Word and Microsoft Office VBA Macros

How-to books on Word programming That Don't Stink

Here's my take on the Word macro books available today, including short capsule reviews. But first, some background on why there are so few quality books on writing macros for Microsoft Word.

 

For your convenience, recommended books include a link to Amazon. Clicking the link opens a new browser window, where you can read more about the book. If it looks promising, it can be ordered directly from amazon.com.

 

What's the Problem with Computer Books, Anyway?

The computer book industry has gone through tumultuous change in the last few years. The combination of publishing for "Dummies" and "Idiots," along with an explosion of Internet-related titles and the general downturn in the market since 9/11, has caused a dearth in quality books on applications software.

 

No where is this dearth more evident in good books on intermediate- and advanced-level topics for Microsoft Word. The situation is even worse for WordPerfect. (The situation isn't as bad for books on Excel and Access, both of which enjoy a fairly large selection.)

 

Book selling is a matter of shelf space. Bookstores want to see each linear foot of their shelves generate a certain amount of money per month. Though they sold relatively slowly, more high-level applications books were available in the "good old days" because bookstores kept them on the shelf months at a time. Now, computer books are routinely returned to the publisher if they aren't sold within 45-60 days. Given the "cost" of bookstore shelf space, even a good book on Word macro writing might not have the chance to generate sales to sustain its publication. It simply is too "unique" of a topic.

 

The net result is that advanced books about using applications software are becoming more and more rare. Visit most any bookstore and you'll see the shelf space for all books on Word is scant, in direct defiance to the immense popularity of the program. Books on advanced topics, like macro writing, are even less common.

 

Books on Word VBA (and VBA in general)

The books that follow describe writing automation solutions (i.e. macros) using Visual Basic for Applications. Some are specific to Microsoft Word, while others discuss VBA as a programming platform. These latter books usually contain at least one chapter on automating Word tasks. They are particularly handy if you need to interoperate between several Word applications, such as Outlook and Word, or Word and Excel.

 

Mastering Microsoft VBA (Second Edition)
Guy Hart-Davis - Sybex, 2005
This a good book for those just starting out, as well as those with some experience in VBA to learn (or re-learn) the finer points of the process. If you already know something about writing VBA macros, you may wish to skim the first few introductory chapters, and go right to the middle of the book.

 

The bulk of Mastering Microsoft VBA covers general-purpose VBA, and it's not until page 441 until we get into the "Applications" part of VBA. The author provides several Word-specific chapters, mostly covering general topics such as inserting text and creating tables. Other application-specific chapters cover Excel, PowerPoint, Access, and Outlook.

 

Word 2003 Document Automation with VBA, XML, XSLT, and Smart Documents
Scott Driza - Wordware Publishing, Inc., 2005
This book focusses on leveraging VBA with other modern technologies to develop document automation solutions. There is quite a bit of introductory and intermediate information on using VBA, but a good deal of the book is on extending VBA's natural abilities using XML and XSLT. Author Driza makes no assumptions as to your familiarity with XML, and explains the basic concepts and advantages. He also details XSLT and style sheets, and it is used to transform XML files into formatted human-readable documents.

 

Microsoft Office Programming: A Guide for Experienced Developers
Rod Stephens - Apress, 2003
Author Stephens likes to write books aimed at the more seasoned professional, and this one is no exception. Microsoft Office Programming is intended for the reader already familiar with the basic concepts of VBA in Word and other Office applications. Still, there's plenty of what I'd call introductory instruction here, like customizing keyboards and menus. The coverage of Word is adequate, though obviously I like to see more emphasis on Word than what is usually found in these grab-bag VBA books. This edition was written for Office XP (Office 2002), and there's a chapter on Office 2003 that discusses differences, and a chapter on Smart Tags.

 

VBA Developer's Handbook, 2nd Edition
Getz, Gilbert - Sybex, 2001
A little old in the tooth but still valid, this is a book for the intermediate and advanced user. Authors Getz and Gilbert have obviously put a lot of time and effort into this book, which includes copious amounts of example code. Some of the content of VBA Developer's Handbook is pure esoterica. For example, only a handful of VBA developers will ever have a need to access non-client metrics (window settings like border width or icon size). Still, if that's your bag, it's a good example of the level of detail found in this book.

 

VB and VBA in a Nutshell: The Languages
Paul Lomax - O'Reilly Media, 1998
Though over 10 years old, this somewhat dry but authoritative edition is still relevant today. It is comprised chiefly of an alphabetical list of VB/VBA statements, complete with syntax, notes, and short examples. This book dwells on the programming language shared by Visual Basic and VBA (after a valiant attempt, it fails to fully explain the differences). It's important to note that VB and VBA in a Nutshell lacks information on using VBA for any given application, like Word and Excel.

Honorary Mentions

Office VBA Macros You Can Use Today: Over 100 Amazing Ways to Automate Word, Excel, PowerPoint, Outlook, and Access
Gonzalez, et al - Holy Macro! Books, 2006

 

Absolute Beginner's Guide to VBA
Paul McFedries - Que, 2004

 

Word Hacks: Tips & Tools for Taming Your Text
Andrew Savikas - O'Reilly Media, 2004

 

Books on Office .NET Development
and Visual Studio Tools for Office

Most independent and in-house programmers continue to use VBA for automating Word (and other Office) tasks. Ever willing to add yet another technology to the plate, Microsoft offers Visual Studio Tools for Office (VSTO), a set of add-on tools for the Visual Studio .NET 2003 and Visual Studio 2005 programming platforms. These tools offer easier integration with Office products when using Visual Studio.

 

Note that Visual Studio provides a choice of programming languages, among them Visual Basic, Visual C# (A C-like language with certain modifications), Visual J# (similar to Java) and Visual C++ -- and in that order of increasing difficulty of learning. All of the books that follow are written for either Visual Basic or C#, and a a couple provide example code in both.

 

A few of the books detail integrating .NET and Office without VSTO, useful if you're working with versions of Word/Office that do not support VSTO.

 

Word 2007 Document Automation with VBA and VSTO
Driza - Jones-Bartlett, 2009
Another big book by author Scott Driza, this version of his document automation book concentrates on VBA and VSTO for Word 2007 and later. Unlike VSTO-specific books, this one also covers automation from the more common VBA perspective, which is useful if you want to compare approaches to see which one is better for a given application.

 

Visual Studio Tools for Office: Using C# with Excel, Word, Outlook, and InfoPath
Carter, Lippert - Addison-Wesley, 2005
This is a hefty tome (over 1,000 pages) that is sure to be one of the leading titles in VSTO programming. True to its title, the book breaks up its Office coverage with separate chapters develoted to Excel, Word, Outlook, and Infopath -- the latter a technology bridge to develop XML-based data entry forms.

 

The same authors offer an Office 2007-specific version of the book as well.

 

Microsoft .NET Development for Microsoft Office
Andrew Whitechapel - Microsoft Press, 2004
This is Microsoft's sponsored book on leveraging Visual Studio development with Microsoft Office, without using VSTO. The techniques covered in this book are relevent when integrating with earlier versions of Office that do not support VSTO, or if you don't wish to use VSTO because of its cost.

Honorary Mentions

VSTO for Mere Mortals: A VBA Developer's Guide to Microsoft Office Development Using Visual Studio 2005 Tools for Office
McGrath, Stubbs - Addison-Wesley, 2006

 

Office 2003 Programming: Real World Applications
Ty Anderson - Apress, 2004

 

Professional VSTO 2005: Visual Studio 2005 Tools for Office
Alvin Bruney - Wrox, 2006

 

Books on Using XML In Office

Automation does not strictly require traditional programming. With XML and XSLT, for example, it's possible to produce the content of documents, and format them in a variety of ways, with little or no programming code. The following books deal with adapting XML strategies in Word and other Microsoft Office applications.

 

Office 2003 XML
St. Laurent, Lenz, McRae - O'Reilly Media, 2003

 

Office 2003 XML for Power Users
McDonald - APress, 2004