不好意思,在 杜先生 面前 献丑了!算 抛砖引玉 吧!(休息了 4 个多月,没怎么编程。)
请 楼主 备份原文件后应用下面代码:
- Sub 日期转大写()
- With Selection
- .WholeStory
- .Font.Color = wdColorAutomatic
- .Find.ClearFormatting
- Do While .Find.Execute("[0-9]{4}年[0-9]{1,2}月[0-9]{1,2}日", , , 1, , , 1)
- .Font.Color = wdColorRed
- With .Find
- .Execute "0", , , 1, , , , , , "零", 2
- .Execute "1", , , 1, , , , , , "一", 2
- .Execute "2", , , 1, , , , , , "二", 2
- .Execute "3", , , 1, , , , , , "三", 2
- .Execute "4", , , 1, , , , , , "四", 2
- .Execute "5", , , 1, , , , , , "五", 2
- .Execute "6", , , 1, , , , , , "六", 2
- .Execute "7", , , 1, , , , , , "七", 2
- .Execute "8", , , 1, , , , , , "八", 2
- .Execute "9", , , 1, , , , , , "九", 2
-
- '特殊情况
- .Execute "一零月", , , 1, , , , , , "十月", 2
- .Execute "零日", , , 1, , , , , , "十日", 2
- If Selection Like "*月[一二三四五六七八九][一二三四五六七八九]日" Then
- Selection.Characters(Len(Selection) - 2).InsertAfter Text:="十"
- End If
- If Selection Like "*一[一二]月*" Then Selection.Characters(6).Text = "十"
- .Execute "一十", , , 1, , , , , , "十", 2
- End With
- .Collapse 0
- Loop
- .HomeKey unit:=wdStory
- End With
- MsgBox "处理完毕!!!!!!", 48 + 0
- End Sub
复制代码 |