Office Word Library - 通过通配符搜索的结果
我有一个 MS Word 2003 文档,其中包含 /FirstName/、/LastName/
等占位符...我使用 Microsoft Office 12 Library 读取文件并使用 Find 通过通配符进行搜索.Text =“/[AZ]*/”
。它工作正常,Find.Execute
确实准确地找到了占位符。但因为它只返回布尔值,所以我不知道如何获取占位符本身。
您能告诉我如何获取通过通配符选项搜索的文本吗
I have a MS Word 2003 documents that contains placeholders such as /FirstName/, /LastName/
, etc... I used Microsoft Office 12 Library to read the file and search by wildcards with Find.Text = "/[A-Z]*/"
. It works fine, and Find.Execute
does find the placeholder exactly. But because it returns only the boolean value, I don't know how to get the placeholder itself.
Can you please show me how to get the text that is searched by a wildcard option
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议使用单词书签而不是占位符,因为文本不会向用户显示,您可以使用此功能在您想要的任何位置自动插入文本,因为您可以获得特定书签的范围:
I would suggest using word bookmarks instead of placeholders, because the text isn't shown to the user and you could use something la this to automatically insert text wherever you want because you can get the range of a specific bookmark:
这是我的代码,供您参考。
首先,这是
letter.doc
文件我还有一个
Dictionary存储每个占位符的键/值的数据
我有一个读取 .doc 文件并替换占位符的方法:
Here is my code, for your interest.
Firstly, this is the
letter.doc
filesI also have a
Dictionary<string, string> Data
that store the key/value for each placeholderAnd I have a method that reads the .doc file and replaces the placeholders :