|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
楼上朋友,权威代码在此:
- Sub 全角字母数字转半角()
- Dim i As Paragraph, mt, r As Range, n%, m%
- With CreateObject("vbscript.regexp")
- .Pattern = "[A-Za-z0-9“”]"
- .Global = True
- .IgnoreCase = False
- .MultiLine = True
- For Each i In ActiveDocument.Paragraphs
- For Each mt In .Execute(i.Range.Text)
- m = mt.FirstIndex: n = mt.Length
- With ActiveDocument.Range(i.Range.Start + m, i.Range.Start + m + n)
- If .Text Like "[“”]" Then .CharacterWidth = wdWidthFullWidth Else .CharacterWidth = wdWidthHalfWidth
- End With
- Next
- Next
- End With
- End Sub
- Sub 半角标点转全角()
- Dim d, x, y, k, t, i%, j%
- x = Array(".", ",", ";", ":", "!", "?")
- y = Array("。", ",", ";", ":", "!", "?")
- Set d = CreateObject("Scripting.Dictionary")
- For i = 0 To UBound(x)
- d(x(i)) = y(i)
- Next
- k = d.keys: t = d.items
- With ActiveDocument.Content.Find
- For j = 0 To d.Count - 1
- .Execute "([一-﨩^13^11])" & k(j) & "([0-9一-﨩^13^11])", , , 1, , , , , , "\1" & t(j) & "\2", 2
- Next
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|