Have you ever needed to make a list of every word in a document? If so, here's a macro that will do it for you automatically. Basically, the macro marks an index entry for every word in your document, generates the index, and removes the page numbers, leaving you with an alphabetical list of words used (at the end of the document). It's sometimes interesting to see what Microsoft Word considers a "word"; periods, commas, and other unlikely items will be included.
To use the macro, open a document for which you need to make a concordance. (Be sure to keep a backup, just in case.) Then, run the following macro on the document (I've included comments to explain how it works):
Sub MakeConcordance()
'Courtesy of the Editorium
'http://www.editorium.com
'Mark an index entry for each word in the document:
Dim myWord
For Each myWord In ActiveDocument.Words
ActiveDocument.Indexes.MarkEntry Range:=Selection.Range, Entry:=myWord
Next myWord
'Go to the end of the document:
Selection.EndKey Unit:=wdStory
'Mark place with a bookmark:
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="IndexStartsHere"
'Generate an index based on the entries marked earlier:
With ActiveDocument
.Indexes.Add Range:=Selection.Range, HeadingSeparator:= _
wdHeadingSeparatorNone, Type:=wdIndexIndent, RightAlignPageNumbers:= _
False, NumberOfColumns:=1, IndexLanguage:=wdEnglishUS
.Indexes(1).TabLeader = wdTabLeaderDots
End With
'Go back to the bookmark:
Selection.GoTo What:=wdGoToBookmark, Name:="IndexStartsHere"
'Select the index, from the bookmark to the end of the document:
Selection.EndKey Unit:=wdStory, Extend:=wdExtend
'Turn the index "field" into actual text:
Selection.Fields.Unlink
'Get rid of the page numbers after the index entries:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ", [0-9]@[^013]"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
'Go back to the bookmark:
Selection.GoTo What:=wdGoToBookmark, Name:="IndexStartsHere"
End Sub
If you don't know how to use such macros, you can find out here.
If you want to keep the page numbers, just leave out these lines:
'Get rid of the page numbers after the index entries:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ", [0-9]@[^013]"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
For certain kinds of projects (catalogs, for example), you may be able to use a concordance to create an index of your document. You can learn more here:
http://lists.topica.com/lists/editorium/read/message.html?mid=1714146574
Need to create a concordance for a whole bunch of documents at once? Use our MultiMacro program to run the macro above on all documents in a folder:
http://www.editorium.com/14844.htm
Or, you could use our WordCounter program, which now includes a concordance feature with a frequency count of the words in a document or documents. (This is a free upgrade for registered users.)
http://www.editorium.com/counter.htm
In other words, WordCounter can now tell you *how many times* each word has been used. How might that be useful for editing? Stay tuned. Over the next few weeks, I'll reveal all.
_________________________________________
READERS WRITE
Neman Syed wrote:
A colleague of mine recently asked me if there was a keyboard shortcut to modify styles (I love keyboard shortcuts 🙂 and I showed him how to assign shortcut keys to Word commands and deal with the Task Pane. Office XP has very poor native keyboard alternatives for the Task Pane, to the point I hardly ever use them, with just a couple of exceptions:
* F6 toggles between the document and the Task Pane. You can then use up/down/tab/shift-tab/enter/alt-down (to open drop-down lists), etc.
* CTRL-TAB cycles through the Task Pane, toolbars, and menu, when you're in one of the Task Pane, toolbars, or menu. If you're in the document, it puts a tab.
Realizing that making these shortcuts may be useful for others (and triggered by Pamela's observation in the 2004-05-12 broadcast that one person's obvious is another person's stunner 🙂 here's my method for solving "Joe's Problem": Assign the keyboard shortcut of ALT-M to the FormatStyleModify command.
Here's how:
1. Tools > Customize.
2. Commands > Keyboard.
3. From the Format category on the left, choose FormatStyleModify on the right.
4. Assign ALT-M or whatever keyboard shortcut you want in the "Press new shortcut key" box. If you choose something that already has an assignation, you'll see it noted in an unobtrusive manner below.
********************************
4a. If desired, change the template from Normal.dot to whatever document/template you want this to apply to. Obviously this selection influences what machines this keyboard shortcut is available on; in Windows 2000 and above, this may only be for the current user. In my case I keep all my modifications, macros, etc. in a file called custom.dot which I automatically throw into Word's Startup folder whenever I'm on a new machine. It's portable and powerful. Note: Only open documents and their templates are eligible candidates here, so to use my personal approach you'll need to manually open whatever startup template/add-in you use to store all your customizations.
********************************
5. OK your way back to your doc.
Your ALT-M shortcut now modifies whatever style your cursor is sitting in. (Not surprisingly, character takes precedence over paragraph.) It certainly saves me time and trouble, and I hope it will for your readers, too!
Many thanks to Neman for this terrific tip.
_________________________________________
RESOURCES
Not to toot my own horn, but I was recently looking through the back issues of this newsletter, available here:
http://www.editorium.com/euindex.htm
Wow, there's an awful lot of good information there! If you didn't know about this archive, now you do. I hope you find it useful.
You must be logged in to post a comment.