|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- '第一条转第1条
- 'Sub 删除所有空格()
- 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 '删除所有空白区域
- '选定字符间循环--选定字符字长=v,循环次数=i
- 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 = "1"
- ElseIf 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 = "佰"
- 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
复制代码 |
|