改变背光

时间:2016-08-11 13:36:54

标签: regex vba text backlight

在Word文档中,我有一个片段(在“{”)之前有空格:

    {""start":   15.4, "end":    31.5, "content": ”SOME_TEXT”.",},

'start'和'end'和'content'之间的数字是变量。如何仅在SOME_TEXT上设置背光黄色?

但有时,在“SOME_TEXT”中是html标签:

<br>, </br>, <ul>, </ul>, <li>, </li>, <b>,</b>, <i>, </i>, <u>, </u>

1 个答案:

答案 0 :(得分:0)

我找到并修改了这段代码,但我不知道,如何为数字和SOME_TEXT添加'TargetList'变量。

Sub test_highlight()

Dim range As range Dim i As Long Dim TargetList

TargetList = Array("<ul>", "</ul>", "<li>", "</li>", "<br>", "</br>", "<b>", "</b>", "        {""start"":   ""end"": ,""content"":""SOME_TEXT."",}, ")

For i = 0 To UBound(TargetList)

Set range = ActiveDocument.range

With range.Find .Text = TargetList(i) .Format = True .MatchCase = True .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False

Do While .Execute(Forward:=True) = True range.HighlightColorIndex = wdWhite

Loop

End With Next

End Sub