View Single Post
  #9   Report Post  
helen
 
Posts: n/a
Default

I love the idea of using a style and macro but I am already using styles
(paragraph styles?) in my document (Heading 1, Heading 2, Heading 3, body
text, etc) - how do I also use an 'index' character style without goofing up
the existing styles? The existing styles are used primarily as the basis for
my TOC...

"Klaus Linke" wrote:

Hi Helen,

A trick I use is to apply a character style "Index" to all prospective index entries, and then use a macro to add XE fields for them when the document is done (see macro below).
You might still want to check each entry once (EditFind "^d XE" and have a quick look), and modify the text that shall appear in the index if needed (singular versus plural, capitalization, sub-entries, ...).

Greetings,
Klaus

Sub IndexForCharStyle()
Dim myCharStyle As String
Dim myEntry As String
Dim myField As Field

myCharStyle = "Index"
Selection.HomeKey (wdStory)
With Selection.Find
.ClearFormatting
.Style = myCharStyle
.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
End With
While Selection.Find.Execute
myEntry = Selection.Text
Selection.Collapse (wdCollapseEnd)
Selection.Fields.Add _
Range:=Selection.Range, _
Type:=wdFieldIndexEntry, _
Text:=Chr(34) & Trim(myEntry) & Chr(34) ' & " \f ""m"""
Selection.Collapse (wdCollapseEnd)
Wend
Selection.EndKey Unit:=wdStory
Selection.TypeParagraph
' change the index field (language ...)
' below, or insert it by hand
Selection.Fields.Add _
Range:=Selection.Range, _
Type:=wdFieldIndex, _
Text:="\c ""1"" \z ""1031"" \f ""m"""
Selection.WholeStory
Selection.Fields.Update
Selection.Collapse (wdCollapseEnd)
ActiveWindow.View.ShowFieldCodes = False
' If you want to immediately remove the index fields:
' For Each myField In ActiveDocument.Fields
' If myField.Type = wdFieldIndexEntry Then
' If InStr(myField.Code.Text, "\f ""m""") 0 Then
' myField.Delete
' End If
' End If
' Next myField
End Sub




Helen wrote:
So - the answer is to go through the entire document sentence by sentence and
not each entry with an XE field? Any 'tricks' to speeding up that process?

"Suzanne S. Barnhill" wrote:

Singular vs. plural, I expect.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Klaus Linke" wrote in message
...
No, they don't have XE fields because he was using a concordance,

Missed the part about the "index table".

and concordances take a notoriously literal view of indexing.

Beyond the capitalization problem I mentioned?

Regards,
Klaus