Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
The Sexton The Sexton is offline
external usenet poster
 
Posts: 1
Default Create index of all words in document & page No. they appear on

I would like to create a simple index of all the words in a Word document &
at the end of each line show the page number on which that word appears.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Herb Tyson [MVP] Herb Tyson [MVP] is offline
external usenet poster
 
Posts: 2,936
Default Create index of all words in document & page No. they appear on

The best way to do this would probably be to write a macro that selects a
word, creates an index entry, then moves on to the next word, and repeats.
One way to do this would be to record a macro as you perform the steps for
the first one, then modify the macro to add control statements that cause
the macro to repeat until reaching the end of the document.

For help with this, your best best would be to visit one of the communities
that is more geared to using VBA in Word, such as
microsoft.public.word.vba.general or microsoft.public.word.vba.beginners.

--
Herb Tyson MS MVP
Author of the Word 2007 Bible
Blog: http://word2007bible.herbtyson.com
Web: http://www.herbtyson.com


"The Sexton" The wrote in message
...
I would like to create a simple index of all the words in a Word document &
at the end of each line show the page number on which that word appears.


  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Poprivet Poprivet is offline
external usenet poster
 
Posts: 160
Default Create index of all words in document & page No. they appear on

Herb Tyson [MVP] wrote:
The best way to do this would probably be to write a macro that
selects a word, creates an index entry, then moves on to the next
word, and repeats. One way to do this would be to record a macro as
you perform the steps for the first one, then modify the macro to add
control statements that cause the macro to repeat until reaching the
end of the document.
For help with this, your best best would be to visit one of the
communities that is more geared to using VBA in Word, such as
microsoft.public.word.vba.general or
microsoft.public.word.vba.beginners.

"The Sexton" The wrote in message
...
I would like to create a simple index of all the words in a Word
document & at the end of each line show the page number on which
that word appears.


That would probably work, but ... such an index is a monster to make useful.

e.g. an index for the sentence above would contain EVERY word in it! e,g,

that,
would,
probably,
work,
but,
such,
an,
index,
etec
etc
etc..

but alphabetically arranged, or course.

Do that on a whole document and you have a real mess, and a large one at
that g.

HTH
Pop`


  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Herb Tyson [MVP] Herb Tyson [MVP] is offline
external usenet poster
 
Posts: 2,936
Default Create index of all words in document & page No. they appear on

Oh. I fully agree. I was simply providing an answer to the question that was
asked. If someone is assembling a monster, I'm happy enough to show where
the neck bolts are kept. :-)

But, on a serious note... sometimes you have to try something in order to
get an idea of how it might be done better.

--
Herb Tyson MS MVP
Author of the Word 2007 Bible
Blog: http://word2007bible.herbtyson.com
Web: http://www.herbtyson.com


"Poprivet" wrote in message
...
Herb Tyson [MVP] wrote:
The best way to do this would probably be to write a macro that
selects a word, creates an index entry, then moves on to the next
word, and repeats. One way to do this would be to record a macro as
you perform the steps for the first one, then modify the macro to add
control statements that cause the macro to repeat until reaching the
end of the document.
For help with this, your best best would be to visit one of the
communities that is more geared to using VBA in Word, such as
microsoft.public.word.vba.general or
microsoft.public.word.vba.beginners.

"The Sexton" The wrote in message
...
I would like to create a simple index of all the words in a Word
document & at the end of each line show the page number on which
that word appears.


That would probably work, but ... such an index is a monster to make
useful.

e.g. an index for the sentence above would contain EVERY word in it! e,g,

that,
would,
probably,
work,
but,
such,
an,
index,
etec
etc
etc..

but alphabetically arranged, or course.

Do that on a whole document and you have a real mess, and a large one at
that g.

HTH
Pop`



  #5   Report Post  
Posted to microsoft.public.word.docmanagement
The Sexton[_2_] The Sexton[_2_] is offline
external usenet poster
 
Posts: 2
Default Create index of all words in document & page No. they appear o

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 €“ theres 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.

"Herb Tyson [MVP]" wrote:

Oh. I fully agree. I was simply providing an answer to the question that was
asked. If someone is assembling a monster, I'm happy enough to show where
the neck bolts are kept. :-)

But, on a serious note... sometimes you have to try something in order to
get an idea of how it might be done better.

--
Herb Tyson MS MVP
Author of the Word 2007 Bible
Blog: http://word2007bible.herbtyson.com
Web: http://www.herbtyson.com


"Poprivet" wrote in message
...
Herb Tyson [MVP] wrote:
The best way to do this would probably be to write a macro that
selects a word, creates an index entry, then moves on to the next
word, and repeats. One way to do this would be to record a macro as
you perform the steps for the first one, then modify the macro to add
control statements that cause the macro to repeat until reaching the
end of the document.
For help with this, your best best would be to visit one of the
communities that is more geared to using VBA in Word, such as
microsoft.public.word.vba.general or
microsoft.public.word.vba.beginners.

"The Sexton" The wrote in message
...
I would like to create a simple index of all the words in a Word
document & at the end of each line show the page number on which
that word appears.


That would probably work, but ... such an index is a monster to make
useful.

e.g. an index for the sentence above would contain EVERY word in it! e,g,

that,
would,
probably,
work,
but,
such,
an,
index,
etec
etc
etc..

but alphabetically arranged, or course.

Do that on a whole document and you have a real mess, and a large one at
that g.

HTH
Pop`




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Will Word 2007 index all words in a document? Emailme Microsoft Word Help 2 April 21st 08 11:26 PM
How do I create an Index with both Capital & Lower cse words? rdrolle Microsoft Word Help 2 September 1st 06 07:41 PM
How do I index all words in a document? JeffUnger Microsoft Word Help 1 March 23rd 06 08:42 PM
how do I generate an index for all the words in the document? profitspublishing Microsoft Word Help 1 February 11th 05 04:40 PM
How do I index all words in an msword document? Adam Rabinowitz Microsoft Word Help 0 January 11th 05 03:21 PM


All times are GMT +1. The time now is 07:44 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"