Index or Extraction method

  • Thread starter Thread starter Guy Lydig
  • Start date Start date
G

Guy Lydig

Is it possible to create an index based on a font size or is there a way to
extract text based on a font size? I am writing a dictionary and the defined
words/phrases are in 8 pt. while the definitions are in 6 pt. I want to
extract a list of all defined words without the definitions so I can check
for duplicates.

Suggestions or ideas would be greatly appreciated.

Guy
 
The following macro will extract all the words formatted in 8 point font
size from the current document, list them in another document, sort them
alphabetically and highlight duplicated words. The original document is
unaffected.

Sub ExtractWords()
Dim SourceDoc As Document
Dim TargetDoc As Document
Dim oPara As Paragraph
Set SourceDoc = ActiveDocument
Set TargetDoc = Documents.Add
For Each oWord In SourceDoc.Range.Words
If oWord.Font.Size = 8 Then
TargetDoc.Range.InsertAfter oWord & vbCr
End If
Next oWord
TargetDoc.Range.Sort
TargetDoc.Paragraphs(1).Range.Delete
For Each oPara In TargetDoc.Paragraphs
On Error Resume Next
If oPara.Range.Text = oPara.Next.Range.Text Then
oPara.Next.Range.HighlightColorIndex = wdYellow
End If
Next oPara
End Sub

http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top