Word

Tag All Instances of a Selection

Ease of Use

Easy

Version tested with

2002 

Submitted by:

EricFletcher

Description:

Sets all other instances of the current selection in a distinctive color and turns off proofing. 

Discussion:

Attach this macro to a button on a toolbar you can use during document editing. Then, as you do an edit pass through a document, use it to flag all instances of words or phrases that will otherwise trip up a spell check: foreign terms, odd names, weird spellings, etc. As presented here, you'll end up with all flagged items set in green text and spell-checking turned off. The color is handy because it lets you see that the term has been encountered and you can later use Find & Replace to change the green font color back to automatic. I have other versions set to different colours with the language set to other than my default. For example, as I encounter a French word in an English document, my French button sets it and all other instances of it in blue with language=French (Canada). This way, the spell check switches on the fly to the appropriate language. Moreover, as I do a spell check and encounter a foreign term, I can drop out and flag it; thus avoiding having to deal with it again if I need to spell check a version of the document again later. 

Code:

instructions for use

			

Sub FlagThis() ' ' FlagThis Macro ' Flags current selection as green with no proofing throughout the document. EJF ' Dim flagit As String flagit = Selection Selection.MoveLeft Unit:=wdCharacter, Count:=1 With ActiveDocument.Content.Find .ClearFormatting .Text = flagit With .Replacement .Text = "^&" .ClearFormatting .Font.Color = wdColorGreen '-- change the colour above if you want something other than green .NoProofing = True '-- You can set a specific language instead of NoProofing if applicable '-- For example: .LanguageID = wdFrenchCanadian End With .Execute Format:=True, Replace:=wdReplaceAll End With Selection.MoveRight Unit:=wdWord, Count:=1 End Sub

How to use:

  1. Open Word.
  2. Press Alt + F11 to open Visual Basic Editor (VBE).
  3. Insert-Module.
  4. Paste the above code in the Module Code Window.
  5. Close VBE (Alt + Q or press the X in the top-right corner).
 

Test the code:

  1. Select some text that is used more than once in a Word document.
  2. Hit Tools-Macro-Macros and double-click FlagThis.
  3. To confirm proofing is turned off, use the What's This from the help menu.
 

Sample File:

FlagThis.zip 9.05KB 

Approved by mdmackillop


This entry has been viewed 81 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express