Sub MarkTextForIndexEntry() ' ' PLEASE READ THE INSTRUCTIONS BELOW: ' ' This MarkTextForIndexEntry Macro works on MS Word 2000-2003-2007-2010 and ' probably more. Use it to tag highlighted text with a hidden field, ready for ' inclusion in an Index at the back of the manual. It leaves you in the ' 'View Codes' mode, so that you can see exactly the tagged text. ' To revert to normal view, use keyboard shortcut Ctrl+Shift+* (asterisk). ' ' It's better than Microsoft's manual tagging method, because it removes bold or italic ' character formatting from words inserted in the Index, so that they ' all look the same. ' ' Copyright 1998-2018 Philip Tory, Gloucester UK ' Supplied free of charge, without support and without warranty of any kind. ' ' KEYBOARD SHORTCUT: We recommend that you link it to a keyboard shortcut Ctrl+Shift+\ ' (the key just left of the Z key). Or choose any easy combination of 3 keys in that corner ' of the keyboard. ' ' For example, in Word 2010, go to menu > File > Options > Customize Ribbon. ' At the bottom of that screen, click on Keyboard shortcuts: > Customize. The Customize ' Keyboard screen appears. ' ' On the left, under Categories, scroll down to Macros and click once to select. ' On thre right under Macros, scroll down to MarkTextForIndexKeyword and click once to select. ' ' Current keys: delete what is there - click to select and then click the Remove button. ' Press new shortcut key: Click once in this box and then press Ctrl+Shift+\ ' Click on the Assign button, then click on the Close button. ' ' Now test the macro! In a word doc, highlight a couple of words in the text, and press the ' Ctrl+Shift+| keys, and it inserts a field containing those words for the index. ' ' ' To use it, just highlight the required key word or phrase, and then press ' Ctrl+Shift+\ to tag it for inclusion in the Index. Quick-And-Easy! ' ' ========= ' IMPORTANT ' ========= ' When you highlight word(s) at the end of a paragraph line, make sure you ' *ONLY* include the exact text characters. *DO NOT* include the invisible ' paragraph marker at the end of the line (the highlight appears to extend ' one space beyond the last letter of the highlighted text) or the macro does not work. ' ' Here is the macro... ' ' Selection.Copy ActiveWindow.ActivePane.View.ShowAll = True ActiveDocument.Indexes.MarkEntry Range:=Selection.Range, Entry:="#", _ EntryAutoText:="#", CrossReference:="", CrossReferenceAutoText:="", _ BookmarkName:="", Bold:=False, Italic:=False Selection.MoveRight Unit:=wdCharacter, Count:=8 Selection.TypeBackspace Selection.Paste Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "XE "" " .Replacement.Text = "XE """ .Forward = False .Wrap = wdFindAsk .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute With Selection .Collapse Direction:=wdCollapseEnd End With With Selection.Find .Forward = True End With ' Remove character formatting to give consistent appearance in the Index: Selection.MoveLeft Unit:=wdWord, Count:=4 Selection.MoveLeft Unit:=wdWord, Count:=3 Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.Font.Reset Selection.MoveLeft Unit:=wdCharacter, Count:=1 End Sub