Etudes for Microsoft Word Programmers

Up ] Resources ] Units ] Terms ] Security ] References ]


Visual Basic was (and probably remains) the number one bestselling language product of all times.

Joel Spolsky [1]

For many years I develop and support server and client software for real time publishing systems (import and export, document servers, layout, web sites etc), which works for years in many newspapers in the USA, Europe and all over the world. Sometimes in the search of the solution for one or other problem I wrote a small program which was easy to experiment with. And, according to the good old tradition I didnít throw that experimental programs away, but spend some extra time to make them complete - finished, commented and good looking etudes which are easy to use and are pleasant to flash back.

My basic and favorite programming language is C++ (best regards to Brian W. Kernighan, Dennis M. Ritchie [2] and Bjarne Stroustrup [3], special thanks for reading and thinking pleasure to Andrei Alexandrescu [4]). But there is one special program among others. It is Microsoft Word plugin for content management system which is built using VBA Ė Visual Basic for Application, that is embedded to all Microsoft Office programs. Namely etudes for Microsoft Word programmers are presented in this book.

All the etudes included are based on real problems. Some problems are simplified. Some solutions are intentionally not finished. In such cases the etude ends with some tasks that present for the readers an opportunity to make the solution perfect. Despite VBA allows easily extend and customize the Microsoft Word capabilities to infinity, usually custom DLLs are used to contact external world (i.e. existing third party programs). Therefore some etudes include complementary DLLs or utilities written in C++. The elegant "Transcriber" etude finishes the book.

The etudes are very different. There are quite small etudes and, on the contrary, long etudes. The etudes are not linked with one another, they just deal with different Microsoft Word objects. You may read any etude (chapter) without assuming knowledge of any previous etude (chapter). Even long etudes are essentially simple, if not light-minded. It is not Toom-Cook multiplication algorithm implementation or searching in growing database problem. All etudes are dedicated to studying Microsoft Word object model capabilities (sometimes little known) using the problems which are at most close to reality.

The brilliant Charles Wetherellís "Etudes for programmers" book [5] exerts obvious influence on the book structure. Manufacturing exists for a lot of time but the value of handicraft only increases. The software is not an exception. Wee-done and reliable software is more often produced by outstanding experts (masters), than by big groups of programmers. Even Microsoft releases software with different reliability.

The users who want to look at the VBA source code should be familiar with Visual Basic Editor (if you are not, just press Alt+F11 and start).

Each chapter (etude) is dedicated to some true problem and contains one or more ready for the use Word plug-ins (sometimes together with additional programs written in C++). Usually the solution is Word plug-in (Word template, file with ".DOT" extension) which contains all macros as well as user interface (as a rule it is a toolbar with some buttons). Installation consists of one step Ė you need to copy the required plug-in to Microsoft Word startup folder. If the solution includes DLLs, then you need to copy them to the Windows system folder. After restarting Microsoft Word the plug-in (and its toolbar) will be available for any open document.

Each chapter begins with the statement of the task. I describe the requirements, user interface and functionality. In fact the task is a brief functional specification (a.k.a. spec) which "describes how a product will work entirely from the user's perspective" [6] (See also [1].). And the more screenshots and pictures the better. Then I discuss the implementation Ė source code, modules, macros and so on. Chapters end with a summary. After the summary there are some tasks for readers. The pretty thing is that an ambitious and aggressive reader may continuously polish up the suggested solutions.

The following table describes the typical chapter structure.

Part of the Chapter


Chapter XXX

Brief introduction to the problem.


Talks about the places where plugins and programs are located. Downloads.


Functional specification (see [7]). Describes how a product will work entirely from the user's perspective. Here I specify userís interface - toolbars, menu and required functionality.


Source code. Modules, forms and macros with authorís comments.


Briefly summarizes what the chapter is about.


Tasks for etude enhancement.

Itís common knowledge that programmers are not keen on writing documentation. Creating specs is out of their responsibility. But specifications are crucial for software to be successful. I hope that after reading some interesting specs you will begin to write your own. According to Joel Spolsky [7] "Specs are motherhood and apple pie". Honestly speaking, not all specs in the book have been written before the code. Some have been written after.

All the etudes were created by me and for me. And despite sometimes it was hard, always with pleasure. Therefore I hope that readers will enjoy them as well.

All included VBA templates are available with source code. You can find fresh versions of software on the bookís home page

There is a popular myth that teachers teach. Itís wrong. People teach themselves taking their own effort. The book is intended to help you to teach yourself. And, please, donít forget that I am not a writer. Iím not even a technical writer. I am Mister Plugin, a programmer.


1. Joel Spolsky "Joel on Software", Apress, 2004.

Joel rocked the VBA cradle in Microsoft. He is the author of the first VBA specification. He was in the Israeli paratroopers in 1986, then graduated from Yale university. But the very interesting occurred later. Joel founded his own software company and shares his success secrets and his ideas (and he has some!) about software industry roadmap with the whole world from 2001. His site is not only one of my favorites, but the best one.
Just type in your browser and start reading.

2. Brian W. Kernighan and Dennis M. Ritchie. The C Programming Language. Prentice Hall. 1972.

Absolutely classic hit. After this book it was impossible to read boring Pascal manuals.

3. Bjarne Stroustrup. The C++ Programming Language (3rd Edition).

Bjarne just got C and enhanced it. An excellent example that demonstrates how one hero could change the world.

4. Andrei Alexandrescu. Modern C++ Design: Generic Programming and Design Patterns Applied. Addison Wesley Professional. 2001.

In 2001 C++ world seemed well known and fully discovered. Amazing Alexandrescu discovered new horizons and again shown that nothing is as simple as it seems.

5. Charles Wetherell. "Etudes for programmers". Prentice Hall. 1978.

I have saved this brilliant book on my shelf up to now.

6. Joel Spolsky. Painless Functional Specifications - Part 2: What's a Spec?

7. Joel Spolsky. Painless Functional Specifications - Part 1: Why Bother?


Etudes for Microsoft Word Programmers. Introduction

Unless otherwise noted, all materials on this site are
© 2000-2009 Evgeny Akhundzhanov, All Rights Reserved Worldwide
Microsoft is in no way affiliated with, nor offers endorsement of, this site. | E-mail the Author