WORD中把选定的数值增大2倍并且颜色改为绿色
来源:百度知道 编辑:UC知道 时间:2024/05/14 06:33:40
把整个文档“万元”前面的数字乘以2。
请写个VBA。谢谢!
运行一下下面的宏, 运行前先备份原文件.
Sub doublenumber()
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Text = "万元"
Selection.Find.Execute
Do Until Selection.Find.Found = False
Selection.MoveLeft
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=True
l = 0
Do While IsNumeric(Selection)
l = l + 1
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=True
Loop
Selection.MoveRight
Selection.MoveLeft Unit:=wdCharacter, Count:=l, Extend:=True
Selection.Text = Val(Selection.Text) * 2
Selection.Font.Color = wdColorGreen
Selection.MoveRight Unit:=wdCharacter, Count:=2 + l
Selection.Find.Execute
Loop
End Sub
子易空间站 - Excel培训专家