利用VBA实现Word与Excel自动化操作
1. Word中的VBA编程
1.1 文本高亮处理
在Word中,我们可以使用VBA代码来处理文本的高亮显示。以下是一段示例代码:
.Highlight = True
.MatchCase = False
‘ Continue until there is nothing else to search.
While DoSearch.Execute()
‘ Remove the highlight as needed.
With CurrPane.Selection.FormattedText
If .HighlightColorIndex = wdTurquoise Then
.HighlightColorIndex = wdNoHighlight
End If
End With
Wend
End With
‘ Go to the beginning of the document.
CurrPane.Selection.GoTo wdGoToLine, wdGoToFirst
End Sub
这段代码的功能是搜索文档中所有高亮显示的文本,并将其中绿松石色( wdTurquoise )的高亮显示移除。代码首先设置搜索条件,然后使用 DoSearch.Execute() 方法进行搜索,当找到符合条件的文本时,检查其高亮颜色是否为绿松石色,如果是则将其高亮颜色设置为无高亮( wdNoHig
超级会员免费看
订阅专栏 解锁全文
3355

被折叠的 条评论
为什么被折叠?



