百科网

首页 > 科技数码

科技数码

vba判断word文字颜色是否为蓝色

科技数码佚名2024-01-02

①第一种代码

On Error GoTo ErrHandle

Set myRange = ActiveDocument.Range(Selection.Start, ActiveDocument.Content.End)

For Each iChar In myRange.Characters

Selection.MoveRight Unit:=wdCharacter, Count:=1

If Selection.Font.ColorIndex = 2 Then MsgBox iChar

Next

Exit Sub

ErrHandle:

MsgBox "Error number: " Str$(Err) Chr(13) Error$(Err), 48, m_Title

②第二种代码