World-宏函数将内容中的英文引号(')全部改成中文的引号(”)
World-宏函数将内容中的英文引号(')全部改成中文的引号(”)
一、文件 - 选项 - 信任中心 - 信任中心设置
二、勾选启用宏 & 开发人员设置
三、Alt + F11
插入- 模块
粘贴以下内容
Sub ReplaceSingleQuotesWithChineseQuotes()
Dim doc As Document
Dim rng As Range
Dim inQuotes As Boolean
Set doc = ActiveDocument
Set rng = doc.Content
inQuotes = False
' 遍历整个文档
With rng.Find
.ClearFormatting
.text = "'"
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = False
Do While .Execute
If inQuotes Then
' 替换为右引号(”)
rng.text = "”"
inQuotes = False
Else
' 替换为左引号(“)
rng.text = "“"
inQuotes = True
End If
' 继续查找下一个
rng.Collapse Direction:=wdCollapseEnd
Loop
End With
MsgBox "英文单引号已替换为中文双引号!", vbInformation
End Sub
四、Alt + F8 点击运行
本文来自博客园,作者:skystrivegao,转载请注明原文链接:https://www.cnblogs.com/skystrive/p/18931335
整理不易,如果对您有所帮助 请点赞收藏,谢谢~