本帖最后由 chuhaiou 于 2016-12-2 09:32 编辑
我想将WORD文档中的红色、蓝色二种字体,每点一次左键,就能从前到后,依次将红色替换成白色,蓝色替换成绿色.试用下程序没反应 : Sub 字体变色() On Error ResumeNext Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .ClearFormatting .Replacement.ClearFormatting If .Font.Color = wdColorRed Then .Replacement.Font.Color =wdColorWhite ElseIf .Font.Color =wdColorBlue Then .Replacement.Font.Color =wdColorGreen End If .Text = "" .Replacement.Text ="" .Forward = False .Wrap = wdFindContinue .Format = True End With With Selection .Find.Execute Replace:=wdReplaceOne .MoveRight Unit:=wdCharacter, Count:=1 .MoveLeft wdCharacter, 1, wdExtend End With End Sub
|