Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-03-2014, 10:37 AM
rjrichar40 rjrichar40 is offline Create an array or list of highlighted text in selection Windows 7 32bit Create an array or list of highlighted text in selection Office 2010 32bit
Novice
Create an array or list of highlighted text in selection
 
Join Date: Aug 2014
Posts: 11
rjrichar40 is on a distinguished road
Default Create an array or list of highlighted text in selection

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!
Reply With Quote
  #2  
Old 09-03-2014, 01:02 PM
gmaxey gmaxey is offline Create an array or list of highlighted text in selection Windows 7 32bit Create an array or list of highlighted text in selection Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create an array or list of highlighted text in selection Formatting- Apply changes to highlighted text results in same change to other text sential Word 6 01-10-2014 03:22 PM
Create an array or list of highlighted text in selection Convert String Array to Integer Array from a User Input? tinfanide Excel Programming 4 12-26-2012 08:56 PM
Create an array or list of highlighted text in selection 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
Create an array or list of highlighted text in selection 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

Other Forums: Access Forums

All times are GMT -7. The time now is 07:49 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft