|
3#
楼主 |
发表于 2010-7-31 19:01:52
|
只看该作者
网上出现的,我自己作了一些修改
Sub ToggleInterpunction() '
Dim ChineseInterpunction() As Variant, EnglishInterpunction() As Variant
Dim myArray1() As Variant, myArray2() As Variant, strFind As String, strRep As String
Dim msgResult As VbMsgBoxResult, N As Byte
'
ChineseInterpunction = Array("1 mol", "=", ",", ";", "∶", "+", "∶", "!", "……", "-", "~", "(", ")", "<", ">", "A.", "B.", "C.", "D.", "A.", "B.", "C.", "D.", "A.", "B.", "C.", "D.", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "0.", "1 g", "2 g", "3 g", "4 g", "5 g", "6 g", "7 g", "8 g", "9 g", "0 g", "b g", "c g", "1 mL", "2 mL", "3 mL", "4 mL", "5 mL", "6 mL", "7 mL", "8 mL", "9 mL", "0 mL", "a mL", "b mL", "c mL", "1 L", "2 L", "3 L", "4 L", "5 L", "6 L", "7 L", "8 L", "9 L", "0 L", "b L", "c L", "2 mol", "3 mol", "4 mol", "5 mol", "6 mol", "7 mol", "8 mol", "9 mol", "0 mol", "a mol", "b mol", "c mol", " ℃")
'
EnglishInterpunction = Array("1mol", "=", ",", ";", ":", "+", ":", "!", "…", "-", "~", "(", ")", "<", ">", "A.", "B.", "C.", "D.", "A. ", "B. ", "C. ", "D. ", "A、", "B、", "C、", "D、", "1、", "2、", "3、", "4、", "5、", "6、", "7、", "8、", "9、", "0、", "1g", "2g", "3g", "4g", "5g", "6g", "7g", "8g", "9g", "0g", "bg", "cg", "1mL", "2mL", "3mL", "4mL", "5mL", "6mL", "7mL", "8mL", "9mL", "0mL", "amL", "bmL", "cmL", "1L", "2L", "3L", "4L", "5L", "6L", "7L", "8L", "9L", "0L", "bL", "cL", "2mol", "3mol", "4mol", "5mol", "6mol", "7mol", "8mol", "9mol", "0mol", "amol", "bmol", "cmol", "℃")
myArray1 = EnglishInterpunction
myArray2 = ChineseInterpunction
strFind = """(*)"""
For N = 0 To UBound(ChineseInterpunction) '从数组的下标到上标间作一个循环
With ActiveDocument.Content.Find
.ClearFormatting '不限定查找格式
.MatchWildcards = False '不使用通配符
.Execute findtext:=myArray1(N), replacewith:=myArray2(N), Replace:=wdReplaceAll
End With
Next
With ActiveDocument.Content.Find
.ClearFormatting '不限定查找格式
.MatchWildcards = True '使用通配符
.Execute findtext:=strFind, replacewith:=strRep, Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True '恢复屏幕更新
End Sub
|
|