View Single Post
 
Old 12-09-2023, 06:29 AM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 293
vivka is on a distinguished road
Default

RobiNew, what do you mean by "extract": hilighting, msgboxing, adding to a collection, deleting...? For me your task is not quite clear.
If you need to hilight the found strings, you may use the followng code, which was once made by gmaxey and slightly modified by me:
Sub Hilite_Array_T()
'In selection, hilite all instances of 'width=' and 'height=' followed
'by three-digit numbers.

Application.ScreenUpdating = False
Dim vFindTxt As Variant
Dim oRng As range
Dim i As Long
vFindTxt = Array("width=", "height=")
For i = 0 To UBound(vFindTxt)
Set oRng = selection.range
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(FindText:=vFindTxt(i), _
MatchWholeWord:=True, _
Forward:=True, _
Wrap:=wdFindStop) = True And _
oRng.End <= selection.range.End
oRng.MoveEnd unit:=wdCharacter, count:=3
oRng.HighlightColorIndex = wdYellow
oRng.Collapse wdCollapseEnd
Loop
End With
DoEvents
Next
lbl_Exit:
Set oRng = Nothing
Exit Sub
Application.ScreenUpdating = True
End Sub
Reply With Quote