9 December 2008

Create a Word Glossary

Microsoft Word has a large number of really useful automation tools when it comes to inserting reference tables such as Contents, Index or a Table of Authorities.  One thing that it really lacks however is a good glossary function.

A document I’m working on at work requires a glossary and rather than scan through the whole document, trying to identify every term or acronym that might need an explanation and then manually writing one out at the end of the document, I decided to mark relevant reference terms in the same way as you might for an index.

The Table of Authorities is probably one of the least-used (and least understood) tables in Word.  It is most commonly used in the legal and public sector industries, but very little outside of those.  However it also a really useful multi-purpose table.  Word 2007 provides a little more by way of functionality (providing a Bibliography in addition to the other references), but still the glossary is missing.

So let’s create our glossary using the Table of Authorities.  What we’re going to do is create a garden-variety TOA first, and then apply a bit of VBA to tidy up the automatically-inserted page number references.

Step 1 – Creating the Table of Authorities (TOA)

The TOA needs to be made up of a collection of marked citations.  You mark a citation by pressing <ALT><SHIFT>I or by navigating through Insert > Reference > Index and Tables, choosing the Table of Authorities tab

Insert Reference

Insert Reference

and clicking the Mark Citation… button.  For each term that you want a glossary entry, mark an occurrence of that term in your document and then enter a description in the “Selected text:” area.

Mark a Citation in Word

Once you’ve marked all the entries you want (you can add more later as required), go to the end of your document (or wherever it is that you want to insert your glossary) and navigate through Insert > Reference > Index and Tables, select the Table of Authorities tab and click OK.  A TOA is automatically inserted into your document.

Step 2 – Formatting the TOA

A TOA by default has page references to any citation in your document.  Glossaries don’t need page numbers so we’re going to want to remove these.  The default TOA also has tab leaders and a heading which are surplus to requirements.  We’ll want to change the field values for the TOA and then apply some code to remove the page numbers.

If you right-click on the TOA you will see a context menu, of which one of the options is “Toggle Field Codes”.  Select this menu item and your TOA will become:
{ TOA \h \c “1″ \p }

In Word speak, this means “insert a Table of Authorities” { TOA; “include a heading” \h; “include items from category 1″ (i.e. the “All” category) \c “3″; and “use passim” \p.  We want to modify this field slightly so that it says:
{ TOA \c “1″ \e “” }

In other words, “insert a Table of Authorities”; “include items from category 1″; “end entries with a blank / empty tab leader”.

If you right-click on the field and choose “Toggle Field Codes” again, press <F9> to refresh your table, a nice new TOA will be presented.  Except for one small detail: those page numbers at the end of each entry.  They must go!

Step 3 – Some Code to Remove Page Numbers

Now here’s the complicated part: Word will automatically insert page number references regardless of the type of index or table you create.  We need to remove these references programatically.  As nice as it would be to be able to remove these numbers either through a switch in the field’s markup or possibly through page formatting, unfortunately this is not possible.  So we’re going to need to include a VBA macro to take that stuff out.

I’ll look at the code for this in part 2 of this blog next week.

Tags: , ,

4 Responses to “Create a Word Glossary”

  1. John says:

    Very useful, but where are the instructions for removing the page numbers? I’d appreciate it if you could add them.

    Thanks

  2. tumiine says:

    Do I have to go through my document and mark the citations? If I have a glossary of terms, can’t word just check my document to see if one of the terms is present and put it in a glossary appendix at the end? thanks.

  3. Phil says:

    You will always need to mark each word that you want included in your glossary because Word won’t recognise which terms you’re interested in automatically. You only need to mark each term once though.

    Word doesn’t start with the glossary, remember – it starts with looking at terms you’ve marked to build that glossary.

Leave a Reply

Real Time Web Analytics