![]() |
#1
|
|||
|
|||
![]()
I am pretty new to VBA so am trying to find my feet to do a task but can't find a sample anywhere to achieve this.
I need to find all highlighted text in a given colour (lets say yellow for now but will want to do blue too) then tag that text with "[color:yellow]" and [/color]. So I can maintain that information on export to another format. So far I have the following, but it has problems. 1. I need to run it multiple times to find each highlight, I just want it to process whole document 2. It doesn't find the yellow highlight on lines that have blue and yellow highlights (so highlighting individual words not a whole paragraph) 3. The end tag goes onto the following line Any guidance would be so much appreciated... Code:
Sub Highlighting() With Selection.Find .ClearFormatting .Replacement.ClearFormatting .MatchWildcards = False .Forward = True .Wrap = wdFindContinue .Highlight = True Do .Execute Loop Until Selection.Range.HighlightColorIndex = wdYellow _ Or Not .Found Selection.Range.InsertBefore "[Color: Yellow ]" Selection.Range.InsertAfter "[/Color]" End With End Sub |
Tags |
highlight, highlight color |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
jackcoletti | Word | 3 | 02-01-2017 08:10 AM |
![]() |
Jonfrank1@me.com | Project | 1 | 01-09-2017 06:04 PM |
![]() |
AustinBrister | Word VBA | 8 | 05-28-2015 02:42 PM |
![]() |
sential | Word | 6 | 01-10-2014 03:22 PM |
Macro for tagging and rearranging selected text for revision | caotico | Word VBA | 0 | 03-28-2012 06:35 PM |