Word中英文引号替换为中文

Sub ReplaceEnglishQuotesWithChinese()

Dim rng As Range

Dim doubleQuoteOpen As Boolean

Dim singleQuoteOpen As Boolean

Set rng = ActiveDocument.Content

doubleQuoteOpen = True

singleQuoteOpen = True

With rng.Find

.ClearFormatting

.MatchWildcards = False

.Forward = True

.Wrap = wdFindStop

.Format = False

.MatchCase = False

.MatchWholeWord = False

' 替换英文双引号

Do While rng.Find.Execute(FindText:="""", Replace:=wdReplaceNone)

If doubleQuoteOpen Then

rng.Text = """

Else

rng.Text = """

End If

doubleQuoteOpen = Not doubleQuoteOpen

rng.Collapse wdCollapseEnd

Loop

' 重设范围

Set rng = ActiveDocument.Content

' 替换英文单引号

Do While rng.Find.Execute(FindText:="'", Replace:=wdReplaceNone)

If singleQuoteOpen Then

rng.Text = "'"

Else

rng.Text = "'"

End If

singleQuoteOpen = Not singleQuoteOpen

rng.Collapse wdCollapseEnd

Loop

End With

MsgBox "英文引号已替换为中文引号!"

End Sub

  • 打开 Word;

  • 按下 Alt + F11 打开 VBA 编辑器;

  • 菜单栏 → 插入 → 模块;

  • 将上面的代码粘贴进去;

  • 关闭编辑器;

  • 在 Word 中按 Alt + F8;

  • 选择 ReplaceEnglishQuotesWithChinese → 点击"运行"

相关推荐
麦序子4 小时前
用 Python + python-docx 批量生成带表格样式的装修报价单 Word 文档(含合计公式)
开发语言·python·自然语言处理·word·python3.11
ms365copilot7 小时前
我不再自己做 Word、Excel 和 PPT 了,我让 Copilot 直接帮我创建 (1)
word·powerpoint·excel·copilot
2501_930707788 小时前
使用C#代码在 Word 中插入或删除分节符
word
wangchunyu11418 小时前
JAVA AQS与Lock实现原理(含CAS)
java·开发语言·word
开开心心_Every1 天前
免费压缩软件WinRAR无弹窗、广告干扰
java·开发语言·前端·spring·智能手机·word·winrar
信可维3 天前
AI 读 Word 表格总读错?先查合并单元格和表头这 3 处
开发语言·人工智能·c#·word·软件工程
andrsted3 天前
练题簿在线免费刷题:将资料、Word 和 PDF导入小程序练习
学习·微信小程序·小程序·pdf·word·学习方法
ProcessOn官方账号3 天前
ProcessOn Office 插件上线:在 Word / Excel / PPT 里直接画流程图
word·excel·插件·office·processon
2501_930707787 天前
使用C#代码在 Word 文档中添加、插入或删除页面
开发语言·c#·word
weixin_416660078 天前
AI 生成的 Mermaid 流程图和 LaTeX 公式,怎么一起导出到 Word?
人工智能·word·流程图·豆包