AlexandarR
08-03-2015, 04:15 AM
Hi!:hi:
I need to find some text within a specific style paragraphs. For example, "Telephone" should be find within the paragraphs which are in "ADDRESS" style.
Already I have done these kind of search within paragraphs enclosed with tags, e.g. <ADDRESS>...</ADDRESS>.
I have furnished the coding below. I need to change the coding for search within "same style paragraphs".
Sub a_Address()
Dim strFind() As String
Dim oRng As Range, oRngTag As Range, oRngLimit As Range, lngIndex As Long
Dim bFound As Boolean
strFind = Split("Telephone|Tel.|Fax|fax", "|")
Set oRng = ActiveDocument.Range
With oRng.Find
Do While .Execute(FindText:="\<ADDRESS\>*\<\/ADDRESS\>", MatchWildcards:=True)
bFound = False
For lngIndex = 0 To UBound(strFind)
Set oRngTag = oRng.Duplicate
Set oRngLimit = oRng.Duplicate
With oRngTag.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWholeWord = True
.MatchCase = True
Do While .Execute(FindText:=strFind(lngIndex), Forward:=True, Wrap:=wdFindStop) = True
bFound = True
With oRngTag
If Not oRngTag.InRange(oRngLimit) Then Exit Do
.HighlightColorIndex = wdTurquoise
.Font.Color = wdColorPink
.Comments.Add oRngTag, "Telephone/Fax no. found"
.Collapse wdCollapseEnd
End With
Loop
End With
Next lngIndex
If Not bFound Then oRng.Comments.Add oRngTag, "Telephone/Fax no. was not found"
oRng.Collapse wdCollapseEnd
Loop
End With
lbl_Exit:
Exit Sub
End Sub
Pl HELP!:help Thanks in advance!
Regards
Alex
I need to find some text within a specific style paragraphs. For example, "Telephone" should be find within the paragraphs which are in "ADDRESS" style.
Already I have done these kind of search within paragraphs enclosed with tags, e.g. <ADDRESS>...</ADDRESS>.
I have furnished the coding below. I need to change the coding for search within "same style paragraphs".
Sub a_Address()
Dim strFind() As String
Dim oRng As Range, oRngTag As Range, oRngLimit As Range, lngIndex As Long
Dim bFound As Boolean
strFind = Split("Telephone|Tel.|Fax|fax", "|")
Set oRng = ActiveDocument.Range
With oRng.Find
Do While .Execute(FindText:="\<ADDRESS\>*\<\/ADDRESS\>", MatchWildcards:=True)
bFound = False
For lngIndex = 0 To UBound(strFind)
Set oRngTag = oRng.Duplicate
Set oRngLimit = oRng.Duplicate
With oRngTag.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWholeWord = True
.MatchCase = True
Do While .Execute(FindText:=strFind(lngIndex), Forward:=True, Wrap:=wdFindStop) = True
bFound = True
With oRngTag
If Not oRngTag.InRange(oRngLimit) Then Exit Do
.HighlightColorIndex = wdTurquoise
.Font.Color = wdColorPink
.Comments.Add oRngTag, "Telephone/Fax no. found"
.Collapse wdCollapseEnd
End With
Loop
End With
Next lngIndex
If Not bFound Then oRng.Comments.Add oRngTag, "Telephone/Fax no. was not found"
oRng.Collapse wdCollapseEnd
Loop
End With
lbl_Exit:
Exit Sub
End Sub
Pl HELP!:help Thanks in advance!
Regards
Alex