【发布时间】:2013-11-22 22:16:04
【问题描述】:
我正在尝试编写一个应用程序来搜索 word 文档中所有出现的 ,其中 some_text 是 之间的任何字符串。当我找到每场比赛时,我想对每场比赛进行存储/显示/做一些事情。
这是我目前所拥有的:
Word._Application word = new Word.Application();
Word.Documents d = word.Documents;
Word._Document doc;
doc = d.Open(strFileName);
doc.Activate();
foreach (Word.Range myStoryRange in doc.StoryRanges)
{
myStoryRange.Find.MatchWildcards = true;
myStoryRange.Find.Text = "[<]*[>]";
myStoryRange.Find.Execute();
// Somehow get the result string that matched the wildcard
}
【问题讨论】:
-
你不能使用正则表达式吗?您无法访问 Word 文档的纯文本吗?
-
您的回复中是否有隐藏的答案?你基本上是在问我刚刚在我的问题中提出的问题。我不知道如何访问Word文档的纯文本。
-
不,没有伪装的答案:> 我只是认为使用正则表达式更有效,更容易。但如果您无法访问纯文本,那就另当别论了。
标签: c# .net ms-word find office-interop