![]() |
|
#1
|
|||
|
|||
|
Noob question...
I have a script that will easily remove any highlighting within the selected text. However, I want to log/track the specific text that is being "un-highlighted" as separate log items (either in an array or list) without including the entire selection. The script I have now just removes any highlighting from anything within the selected range. Any ideas or links to a good script to borrow to obtain the text being un-highlighted? So far, my attempts either log the entire piece of selected text, or just the last item of highlighted text... But not the individual highlighted "chunks" that I want to record. Much appreciated! |
|
#2
|
|||
|
|||
|
Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oCol As New Collection
Dim lngIndex As Long
Selection.Find.ClearFormatting
Selection.Find.Highlight = True
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
While .Execute
Selection.Range.HighlightColorIndex = wdAuto
oCol.Add Selection.Range.Text
Selection.Collapse wdCollapseEnd
Wend
End With
For lngIndex = 1 To oCol.Count
Debug.Print oCol.Item(lngIndex)
Next lngIndex
lbl_Exit:
Exit Sub
End Sub
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Formatting- Apply changes to highlighted text results in same change to other text
|
sential | Word | 6 | 01-10-2014 03:22 PM |
Convert String Array to Integer Array from a User Input?
|
tinfanide | Excel Programming | 4 | 12-26-2012 08:56 PM |
Selection of all Text for a specific page in word is spanning selection across pages
|
ramsgarla | Word VBA | 9 | 12-05-2012 03:23 AM |
Prepare report/list of all highlighted items
|
nrschmid | Word | 1 | 10-05-2011 06:26 PM |
| Highlighted Selection on Action Settings | mos7sad | PowerPoint | 0 | 10-12-2009 07:48 AM |