View Single Post
  #3   Report Post  
Klaus Linke
 
Posts: n/a
Default

Hi,

You can create an index out of all words (phrases) marked in some =
character style "myIndex" with the macro below.
It's still easiest to use the built-in index feature (=3D insert XE =
fields), but you can immediately unlink the index (turn the index field =
into plain text), and delete the XE fields in the same macro.

Regards,
Klaus


Sub CharStyleToIndex()
' marks up all text formatted in some char style
' as index entries
Dim myCharStyle As String
' Insert the name of your char style he
myCharStyle =3D "myIndex"
Dim strEntry As String
Dim strOut As String
Dim start
Application.ScreenUpdating =3D False
ActiveWindow.View.ShowAll =3D False
ActiveWindow.View.ShowHiddenText =3D False
Selection.HomeKey (wdStory)
With Selection.Find
.ClearFormatting
.Style =3D myCharStyle
.Text =3D ""
.Forward =3D True
.Wrap =3D wdFindStop
.Format =3D True
End With
While Selection.Find.Execute
strEntry =3D Selection.Text
ActiveDocument.Indexes.MarkEntry _
Range:=3DSelection.Range, Entry:=3DstrEntry
Selection.Collapse (wdCollapseEnd)
Wend
With ActiveDocument
.Range(.Range.End - 1, .Range.End).Select
Selection.InsertParagraphAfter
Selection.Move Unit:=3DwdCharacter, Count:=3D1
.Indexes.Add Range:=3DSelection.Range, _
HeadingSeparator:=3DwdHeadingSeparatorNone, _
Type:=3DwdIndexIndent, _
RightAlignPageNumbers:=3DFalse, _
NumberOfColumns:=3D2
.Indexes(1).TabLeader =3D wdTabLeaderDots
End With
Selection.MoveStart Unit:=3DwdCharacter, Count:=3D-1
Selection.Fields(1).Unlink
With ActiveWindow
.View.ShowFieldCodes =3D True
.ActivePane.View.ShowAll =3D True
End With
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text =3D "^d XE"
.Replacement.Text =3D ""
.Forward =3D True
.Wrap =3D wdFindContinue
.Format =3D False
.MatchCase =3D False
.MatchWholeWord =3D False
.MatchWildcards =3D False
.MatchSoundsLike =3D False
.MatchAllWordForms =3D False
End With
Selection.Find.Execute Replace:=3DwdReplaceAll
End Sub



"TPlus" wrote:
How can I create a list of specific words used in a document without =

creating=20
a separate marking for them, such as the index uses. Is there anyway =

to use=20
a style that could create a list (using a character style that feeds =

into a=20
TOC entry). It will only be words, not complete sentences.
=20
The issue with a "marked text - duplicate selection of text being =

created"=20
is ensuring that edits are made in the "marked text area" as well. =20
Wordperfect had a listing feature that marked the actual selected text =

and it=20
did not create a duplicate area. Thanks in advance for any ideas or=20
suggestions.