Programming Microsoft Word - 01 - Introduction


I have been planning for several years to automate some of the repetitive Word tasks I encounter on a daily basis. For companies, software development is not something purchased like a box of printer ink and pencils. It involves a lot of planning, testing, interviews and … money. There seems to be no chance in getting your own repetitive tasks automated very quickly. Well, that's were opportunity is arising. Writing software becomes easier and easier. Open source tools but also tools made available by companies like Microsoft increase our ability to be our own developer and solving our own challenges at home and at work.

This contribution to Devtome is intended to be the first of many, describing the steps to develop a software application with free tools (assuming you have MS Word available). A software application that you can fit and mold to your exact requirements, saving you a lot of time and trouble in your future ambitions and work. I am not and will never be a professional coder. It's all about reading, trying out and education oneself in the long run, and making software that works (whether we fully understand it or not). Since I have not encountered a single source of information explaining all basic aspects of building your Word automation project, I have made it my aim to do exactly that. A guide for enthusiasts willing to put in the effort to learn automating their documents.

This first contribution kicks off with a small introduction, followed by setting up the necessary (free) software, and finally building and running a simple program that automates Word. This little program will not be the end - there are a lot of issues with it that need to be solved; something we will tackle in future contributions - but we take it step by step. You will do some coding of yourself. That means you will actually be writing a program and executing it. Don't worry, the code will be provided to you so it can't go wrong. I will use the following box to describe code.

[[ code goes in here ]]

Most of the coding will be done by the programming software. Your task mainly consist of building the user interface with drag and drop and inserting some minimal code at the right spot to make it work. You will learn quickly how it works and become familiar with it.

Automating Microsoft Word

Everybody knows Microsoft Word. This program is still number 1 software used in most businesses and widely known to people all over the world. The amount of hours spent behind a keyboard, typing in letters that form words, that form sentences, that form … etc, is endless. What is less known is Word's design. As from the start, Microsoft made Word very much programmable. In lay men's terms: the ability to let Word do things automatically by means of a program. Some of these automation tasks are already baked in Word itself. An example is the Table of Contents, that can be added to a document with in-build functionality. A rudimentary form of automation that you can build yourself is the macro. Macro's can be created by the Word user by recording a task, which can be repeated by means of this macro endlessly by means of a short-cut or a button assigned to this macro, thus saving the user time and effort. In fact, I think most people already use these automation options of Word, whether by own design or by design of their employer.

However, Word can be automated a lot further.

Assuming that you or your employer already has bought Microsoft Word, you already have a very powerful tool at hand to bring you those documents, letters and reports. Word can do a lot more than just taking keyboard strokes one by one. It is designed to be programmed and steered by external programs in almost every conceivable way. Generally, users do not use even 10% of its capabilities. In conclusion, the complete engine for our automation is already there, bought and paid for.

Required tools

As stated above, I assume you already have Microsoft Word available. It does not matter which version you use. With some small adjustments, the approach to Word automation used in this contribution should work for each recent version of Word. The rest of the software needed is basically one additional program only: Microsoft Visual Studio Express (for Desktop). Since Microsoft came out with.NET, it has also been releasing newer versions of its related programming software: Visual Studio (VS). Whereas the full versions of VS come at a price, Microsoft also makes limited versions of VS freely available: the 'Express' version. With hardware moving from desktop to the web and, nowadays, mobile, there are several different types of Visual Studio Express 2013 to choose from. For this contribution, we will use Visual Studio Express for Desktop 2013.

Download and install Visual Studio Express for Desktop . Installing takes some time. If the program asks you what programming language you will primarily be using, choose Visual Basic. Once installed, you are ready to start with the first program.

Next: Programming Microsoft Word - 02 - Our first program

Computing | Programming | Software

QR Code
QR Code programming_microsoft_word_-_01_introduction (generated for current page)