![]() |
#1
|
|||
|
|||
![]()
Hello Everybody.
I have a code able to highlight all the words in the string ![]() My request here is: first, my list is really long -SO- how can I break it or separated in different lines. Second: how to replace each word in the list for different replacement for each one. This is the code I have: Code:
Sub HiLightList() Application.ScreenUpdating = False Dim keywords As String, Rng As Range, i As Long keywords = "if,then,from,to,all,first,between,first,last,of,and,or,print,find,swap,check,print,count,when,require,do not,with,but, rather than,where,is not,as,in,an,is,by,are,on,for,because,some,before,after,also,under,inside,around,into,next to,often,let,delete,copy,find,calculate,check,print,until,was,were,behind,had been" For i = 0 To UBound(Split(keywords, ",")) Set Rng = ActiveDocument.Range With Rng.Find .ClearFormatting .Text = Split(keywords, ",")(i) .Replacement.ClearFormatting .Replacement.Highlight = True .Replacement.Text = "^l^&" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = True .MatchWholeWord = True .Execute Replace:=wdReplaceAll End With Next Set Rng = Nothing Application.ScreenUpdating = True End Sub |
Tags |
vba |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
wardw | Word | 7 | 05-07-2018 09:13 AM |
![]() |
Amitti | Word VBA | 2 | 04-10-2017 07:35 PM |
How to find all string within string. | PRA007 | Word VBA | 18 | 02-12-2016 08:11 PM |
![]() |
mattyra | Word | 7 | 02-11-2015 11:13 PM |
![]() |
omahadivision | Excel Programming | 12 | 11-23-2013 12:10 PM |