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 → 点击"运行"

相关推荐
江南烟雨尘3 小时前
Zotero管理Word参考文献,更新参考文献
word·论文笔记·zotero·参考文献
2501_9071368221 小时前
Word文档智能排版工具 (Word-Formatter-Pro)
word·软件需求
清风明月一壶酒1 天前
OpenClaw自动处理Word文档全流程
开发语言·c#·word
weixin_416660071 天前
豆包公式转Word,乱码解决
word·latex·豆包
寒山李白3 天前
解决 python-docx 生成的 Word 文档打开时弹出“无法读取内容“警告
python·word·wps·文档·docx·qoder
AI进化营-智能译站3 天前
ROS2 C++开发系列01:在ROS2上编写第一个C++ hello word
开发语言·c++·ai·word
gc_22994 天前
学习C#调用OpenXml操作word文档的基本用法(30:学习日期相关类)
word·openxml·日期
gc_22994 天前
学习C#调用OpenXml操作word文档的基本用法(28:学习文本类)
word·文本·text·openxml
2501_907136824 天前
HandyWrite Pro - word/excel转手写工具
word·软件需求
Eiceblue4 天前
C# 如何实现 Word 转 Excel ?分享两种实用方法
c#·word·excel