资源描述:
《Word中英文标点符号转换.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、1."工具"→"宏"→"VisualBasic编辑器"2."工具"→"宏"→"宏"SubToggleInterpunction()'中英文标点互换DimChineseInterpunction()AsVariant,EnglishInterpunction()AsVariantDimmyArray1()AsVariant,myArray2()AsVariant,strFindAsString,strRepAsStringDimmsgResultAsVbMsgBoxResult,NAsByte'定义一个中文标点的数组对象ChineseInterpunctio
2、n=Array("、","。",",",";",":","?","!","……","—","~","(",")","《","》")'定义一个英文标点的数组对象EnglishInterpunction=Array(",",".",",",";",":","?","!","…","-","~","(",")","<",">")'提示用户交互的MSGBOX对话框msgResult=MsgBox("您想中英标点互换吗?按Y将中文标点转为英文标点,按N将英文标点转为中文标点!",vbYesNoCancel)SelectCasemsgResultCasevbCance
3、lExitSub'如果用户选择了取消按钮,则退出程序运行CasevbYes'如果用户选择了YES,则将中文标点转换为英文标点myArray1=ChineseInterpunctionmyArray2=EnglishInterpunctionstrFind="“(*)”"strRep="""1"""CasevbNo'如果用户选择了NO,则将英文标点转换为中文标点myArray1=EnglishInterpunctionmyArray2=ChineseInterpunctionstrFind="""(*)"""strRep="“1”"EndSelectAp
4、plication.ScreenUpdating=False'关闭屏幕更新ForN=0ToUBound(ChineseInterpunction)'从数组的下标到上标间作一个循环WithActiveDocument.Content.Find.ClearFormatting'不限定查找格式.MatchWildcards=False'不使用通配符'查找相应的英文标点,替换为对应的中文标点.Executefindtext:=myArray1(N),replacewith:=myArray2(N),Replace:=wdReplaceAllEndWithNextW
5、ithActiveDocument.Content.Find.ClearFormatting'不限定查找格式.MatchWildcards=True'使用通配符.Executefindtext:=strFind,replacewith:=strRep,Replace:=wdReplaceAllEndWithApplication.ScreenUpdating=True'恢复屏幕更新EndSub