我有一个巨大的文档,其中应更改以某些特定单词文本样式开头的行。我为所有这些单词创建了一个数组,并尝试使用 For 循环格式化文档。但是只有数组中第一个单词的样式发生了变化,而不是数组中的所有单词。
以下是我所做的,请看一下并提出解决方案:
Sub Variables_NormalTxt()
Dim oRng As Word.Range
Dim oRngFC As Word.Range
Dim varUbyteNormal As Variant
Dim ArrayItem As String
Dim i As Integer
varUbyteNormal = Array("uword", "ubyte", "bool", "sword", "const", "ulong", "static")
Set oRng = ActiveDocument.Range
i = 0
For i = 0 To UBound(varUbyteNormal)
With oRng.Find
.Text = varUbyteNormal(i)
.Font.Name = "Times New Roman"
.Font.Bold = False
.Font.size = 10
While .Execute
oRng.Select
Set oRngFC = ActiveDocument.Bookmarks("\Line").Range
oRngFC.Style = "variable normal"
Wend
End With
Next i
End Sub