Hi
Thanks for all your help.
Found a macro from PC Magazine that does the listing of the words but
doesn't do the page on which the word appears and I'm afraid that it might be
a problem beyond my abilities. This is the text of the macro and I wonder if
either of you know how to modify it to do the page number on which the word
appears.
Once again thanks
CreateListOfWords macro
PCUser Magazine
To run this macro:
1 First put this code into your Normal.dot file (instructions below).
2 Open a file you want to create a word list from. Run the macro
createListOfWords on the file (Tools, Macro, Macros, createListOfWords and
click Run). You will end up with a list of words only, one per line. You know
the macro is finished when you see a message box on the screen. Wait! It will
take some time to run, depending on the file size and the speed of your
computer.
3 Save this file as a plain text file (File, Save As, from the Save as type
list choose Plain Text (*.txt) and give it a name.
4 Open Excel. Open the saved text file (you may have to choose .txt from the
Excel Files of type list in the Open dialog to see the file).
5 Press Finish when the Import Text dialog appears – there’s nothing you
need do.
6 Run the Excel macro calculateFrequency to calculate the frequencies of the
words in the file.
Problems?
If you get a message saying "The macros in the project are disabled. Please
refer to the online help or documentation of the host application determine
how to enable macros", change the macro security level by choosing Tools,
Macro, Security, Security Level tab. Select the Medium option and click OK.
Exit and restart Word for the change to take place. Now, when you open this
file, or any other file which and contains macros, you'll be prompted to
enable or disable the macros -- to run a macro in a file you must choose
Enable Macros.
Macro code
This is the text of the macro:
Sub CreateListOfWords()
'strip out the word "the" and all punctuation. Place one word per line
Set myRange = ActiveDocument.Content
myRange.Find.Execute FindText:=" the ", ReplaceWith:=" ",
Replace:=wdReplaceAll
myRange.Find.Execute FindText:="^p", ReplaceWith:=" ", Replace:=wdReplaceAll
myRange.Find.Execute FindText:=" ", ReplaceWith:=" ", Replace:=wdReplaceAll
myRange.Find.Execute FindText:=" ", ReplaceWith:="^p", Replace:=wdReplaceAll
myRange.Find.Execute FindText:="^p^p", ReplaceWith:="^p",
Replace:=wdReplaceAll
myRange.Find.Execute FindText:=",", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:=".", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:="!", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:=";", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:=":", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:="(", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:=")", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:="~", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:="1", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:="2", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:="3", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:="4", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:="5", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:="6", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:="7", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:="8", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:="9", ReplaceWith:="", Replace:=wdReplaceAll
myRange.Find.Execute FindText:="^t", ReplaceWith:="", Replace:=wdReplaceAll
'remove all 2 and 1 letter words
fcount = ActiveDocument.Paragraphs.Count
For i = fcount - 1 To 1 Step -1
If Len(ActiveDocument.Paragraphs(i).Range) < 4 Then
ActiveDocument.Paragraphs(i).Range.Delete
ElseIf ActiveDocument.Paragraphs(i).Range = "the" Then
ActiveDocument.Paragraphs(i).Range.Delete
End If
Next i
MsgBox "Save the file as a text file and then open it in Excel and run the
frequency macro."
End Sub
You can add more lines to the first part of the macro to strip out other
characters as required. Right now it strips out numbers and basic punctuation
but you may find you use other characters in your text so feel free to add
lines to strip them out too.
Add the macro to Normal.dot
To add this macro to your own Normal.dot file so it is always available when
you start Word, with the file createlistofwords.doc open on the screen,
choose Tools, Macro, Macros, Organizer, Macro Project Items tab. You should
see a dialog with createlistofwords.doc on the left and Normal.dot on the
right. Select the createlistofwords.doc option in the box on the left and
click Copy to move it to the box on the right. Click Close to finish.
Add it to a toolbar button
To add a toolbar button to run this macro, right click any toolbar and
choose Customize, Commands tab. Scroll down to locate the Macros entry in the
Categories list and from the Commands list drag the Normal.
createlistofwords.doc. createlistofwords.doc entry up and onto the toolbar.
Right click the new button and in the Name area give it a shorter name and
click Close in the Customize dialog.