#1
|
||||
|
||||
Find Multiple Wildcard string and Highlight
I want to highlight two identical string if present in word document to be highlighed
For example in my word table there are somuch data with some patent numbers I would like to find the duplicate patent numbers and want to highlight Specific example I have string like this 1. WO 12345 A1 2. US 12345 A2 3. EP 12345 A1 4. WO 12345 A1 5. WO 12345 A3 6. US 12345 A2 Note that above strings are distributed in tables with other data I want to highlight strings which have [A-Z]{2} [0-9]{4,} duplicate. |
#2
|
||||
|
||||
Try:
Code:
Sub Demo() Application.ScreenUpdating = False Dim strTxt As String, i As Long strTxt = "|" With ActiveDocument.Range With .Find .ClearFormatting .Replacement.ClearFormatting .Text = "[A-Z]{2} [0-9]{4,}" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = False .MatchWildcards = True .Execute End With Do While .Find.Found If InStr(strTxt, "|" & .Text & "|") = 0 Then strTxt = strTxt & .Text & "|" Else i = i + 1 .HighlightColorIndex = wdYellow End If .Collapse wdCollapseEnd .Find.Execute Loop End With Application.ScreenUpdating = True MsgBox i & " duplicates found." End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
||||
|
||||
This is really great and sufficient
Thanks |
Tags |
word table, word vba |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find and highlight multiple words in MS Word document | AtaLoss | Word VBA | 37 | 09-22-2021 12:04 PM |
Find/Replace Wildcard Needed-Bold & Highlight | rsrasc | Word VBA | 3 | 11-11-2014 03:55 PM |
Find and highlight multiple words in a document | flatop | Word VBA | 3 | 04-16-2014 10:29 PM |
Extract from String using Wildcard | whousedmy | Word | 0 | 05-21-2009 01:35 AM |
find - reading highlight - highlight all / highlight doesn't stick when saved | bobk544 | Word | 3 | 04-15-2009 03:31 PM |