View Single Post
 
Old 07-06-2020, 07:55 PM
MyUserName123 MyUserName123 is offline Windows 10 Office 2019
Novice
 
Join Date: Jul 2020
Posts: 10
MyUserName123 is on a distinguished road
Default Macro to Mark Text with Index Codes

Hi, I'm trying to write a macro that will go through an entire document, find any text in red font and mark that text with an index code. I've tried many different variations of the code below, but nothing works correctly. This latest attempt just inserts blank index codes at the top of the document, one for each instance of every word in red text. I clearly have no idea what I'm doing. Can anyone help? Thank you in advance for any information.

Code:
  Sub MarkIndexMacro()
  Dim MyRange As Range
  Selection.HomeKey Unit:=wdStory
    Set MyRange = ActiveDocument.Range
      With MyRange.Find
        .Font.Color = wdColorRed
        Do While .Execute
        ActiveDocument.Indexes.MarkEntry Range:=Selection.Range, Entry:=Selection.Range.Text
           Loop
      End With
  End Sub
Reply With Quote