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

相关推荐
揭老师高效办公8 小时前
Word和WPS文字如何制作分栏试卷?想分几栏分几栏
word·wps文字
揭老师高效办公2 天前
在Word和WPS文字中添加的拼音放到文字右边
word·wps文字
_oP_i2 天前
c# openxml 打开加密 的word读取内容
开发语言·c#·word
zzc9213 天前
用python自动标注word试题选项注意事项
python·自动化·word·办公·试题·自动化标记
梦想画家4 天前
Java 动态导出 Word 登记表:多人员、分页、动态表格的最佳实践
java·word·报表模板
诸葛大钢铁5 天前
PDF转Word的简单方法
pdf·word
飛_6 天前
Word Press富文本控件的保存
html·word·word press
海哥编程6 天前
Python 进阶(六): Word 基本操作
python·word
CodeForCoffee7 天前
Word for mac使用宏
word
2301_787725657 天前
HTML 转 Word API 接口
html·word