|
杜先生:我决定选用第二个代码,测试也是如此,比第一个代码快了很多,我略改了一下半角符号的顺序。我有一个新要求:请再完善一下下面的代码(有示例文本),让“联系电话:261-7523“后面的半角冒号变为全角就OK了!还有,请再加一句让各个替换后的标点变红色的代码,我不知怎么加,辛苦,谢谢!
- Sub 替换半角标点为全角()
- 'code by duquancai
- Dim d, x, y, k, t, i%, j%
- x = Array(".", ",", ";", ":", "!", "?")
- y = Array("。", ",", ";", ":", "!", "?")
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- For i = 0 To UBound(x)
- d(x(i)) = y(i)
- Next
- k = d.keys: t = d.items
- For j = 0 To d.Count - 1
- With ActiveDocument.Content.Find
- .ClearFormatting
- .Replacement.ClearFormatting
- .Text = "([一-﨩^13^11])" & k(j) & "([一-﨩^13^11])"
- .MatchWildcards = True
- .Replacement.Text = "\1" & t(j) & "\2"
- .Execute Replace:=wdReplaceAll
- End With
- Next
- Application.ScreenUpdating = True
- End Sub
复制代码
*** 示例文本:
今年,在干部廉洁自律工作方面;将重点抓好思想道德和纪律教育.切实抓好八项要求的落实!中华人民共和国?节约经费3,457.06元,花费45,562.73元.
联系电话:261-6375
句号.逗号,分号;冒号:叹号!问号?开会时间,早8:30~10:00. |
|