如何使用 VBA 循环遍历 MS Word 中的每个字母?
我有大约 100 个 Word 文档,其中包括外国名字的音译。这些文档的作者使用了一种名为e2的特殊字体,它有大约十几个特殊音译字符(所有这些都可以在Microsoft Sans Serif字体中找到)。
我想循环遍历文档的每个字母,每当 .Font = "e2"
我想循环遍历这十几个字母(很容易猜到它们是什么)并将它们替换为相当于 Microsoft Sans Serif。但我不知道如何循环遍历字母。这是否可行,就像循环遍历 Excel 电子表格中的单元格一样?
I have about 100 Word documents which include transliteration of foreign names. The author of these documents used a special font called e2 which has about a dozen special transliteration characters (all of which are available in Microsoft Sans Serif font).
I would like to loop through every letter of the document and whenever the .Font = "e2"
I would like to loop through the dozen letters (it's easy to guess what they are) and replace them with a Microsoft Sans Serif equivalent. But I can't figure out how you can loop though letters. Is that doable like looping through cells in an Excel spreadsheet?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是一种方法,但根据文档的大小,执行可能需要很长时间。
This would be one way to do it, but depending on the size of the document, it may take a long time to execute.
更快:
Way faster:
您还可以将其另存为 docx,在 zip 文件中打开它,然后在 document.xml 和 fontTable.xml 中进行搜索/替换。
You could also save it as docx, open it in a zip file and do a search/replace inside document.xml and fontTable.xml.
使用 mswords 格式查找 &代替。您将节省时间&大文件不会成为问题。
use the mswords format find & replace. You will save time & large file won't be a concern.