|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
给你一个 413191246se 老师的代码,运成试试,参考一下。- Sub test()
- Dim myRange As Range
- If Selection.Type = wdSelectionIP Then Selection.WholeStory
- Set myRange = Selection.Range
- myRange.Find.Execute findtext:=" ", replacewith:=":", Replace:=wdReplaceAll
- myRange.Find.Execute findtext:="^w", replacewith:="", Replace:=wdReplaceAll
- Dim v As Long, i As Long
- Selection.HomeKey Unit:=wdStory
- Selection.Find.ClearFormatting
- Do While Selection.Find.Execute(findtext:="第", Forward:=True)
- Do '外层循环运行。
- Selection.MoveEnd Unit:=wdCharacter, Count:=1
- Loop Until Selection Like "*[!一二三四五六七八九十百零]"
- If Selection Like "*条" Then
- Selection.MoveStart Unit:=wdCharacter, Count:=1
- Selection.MoveEnd Unit:=wdCharacter, Count:=-1
- Selection.Font.Color = wdColorRed
- If Selection Like "十[一二三四五六七八九]" Then
- Selection.Characters(1) = "1"
- Selection.MoveRight Unit:=wdCharacter, Count:=1
- Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
- GoTo Sec
- ElseIf Selection Like "[一二三四五六七八九][十百]" Then
- If Selection Like "*十" Then Selection.Characters(2) = "0" Else Selection.Characters(2) = "00"
- Selection.MoveLeft Unit:=wdCharacter, Count:=1
- Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
- GoTo Sec
- ElseIf Selection Like "???十" Then
- Selection.Characters.Last = "0"
- End If
- Selection = Replace(Selection, "百", "")
- If Len(Selection) >= 3 Then Selection = Replace(Selection, "十", "")
- v = Len(Selection)
- Selection.MoveLeft Unit:=wdCharacter, Count:=1
- Do
- Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
- Sec:
- If Selection = "一" Then
- Selection = "2"
- ElseIf Selection = "二" Then
- Selection = "3"
- ElseIf Selection = "三" Then
- Selection = "4"
- ElseIf Selection = "四" Then
- Selection = "5"
- ElseIf Selection = "五" Then
- Selection = "6"
- ElseIf Selection = "六" Then
- Selection = "7"
- ElseIf Selection = "七" Then
- Selection = "8"
- ElseIf Selection = "八" Then
- Selection = "9"
- ElseIf Selection = "九" Then
- Selection = "10"
- ElseIf Selection = "十" Then
- Selection = "11"
- ElseIf Selection = "百" Then
- Selection = "佰"
- ElseIf Selection = "零" Then
- Selection = "0"
- End If
- Selection.MoveRight Unit:=wdCharacter, Count:=1
- i = i + 1
- Loop Until i = v
- End If
- Selection.MoveRight Unit:=wdCharacter, Count:=1
- i = 0
- Loop
- MsgBox "处理完毕!--下面请自行执行【第一章/条】宏完成第1条加粗任务!", vbOKOnly + vbExclamation, "第一条转第1条"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|