在Word文档中搜索关键字 [英] Searching for keywords in word documents

查看:90
本文介绍了在Word文档中搜索关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我正在使用VS 2005和MFC(请不要使用.Net)
我需要浏览一堆MS Word文档(.DOC,.DOCX),并找到其中具有给定关键字或多个关键字的所有文档.

我该如何编写这样的代码,这将向我返回找到该关键字的Word文档的路径列表,或者如果找不到则为空列表.

干杯,
Alex

解决方案

也许您会发现此CP文章很有帮助:^ ]

我不知道本文是否会回答您的问题,但这可能会带您朝正确的方向.很快就会发现几乎没有C ++/COM的文档了. MSDN似乎只记录了.NET互操作API,如果您的Google技能很好,您也许可以得到较旧的MSDN页面,但是即使那些页面也只有VB6示例.由于您想避免使用.NET,因此我假设您的C ++和COM技能很好.如果是这样,您应该能够在那里基于VB和.NET文档整理一些代码.

这是2004年的一篇体面的文章,展示了如何从VC ++访问Word API:

http://support.microsoft.com/kb/238393 [如何:在文档中搜索文本 [ 解决方案

May be you will find this CP article helpful: MS Office OLE Automation Using C++[^]

I don''t know if the article will answer your question, but it may lead you to the right direction.


You can use Word''s automation API to do this, but you''ll quickly find that there is almost no documentation for C++/COM anymore. MSDN seems to only have the .NET interop API documented, and if your Google skills are good, you may be able to get the older MSDN pages, but even those would only have VB6 examples. Since you want to avoid .NET I assume your C++ and COM skills are good. If so, you should be able to put together some code based on the VB and .NET documentation out there.

Here''s a decent article from 2004 that shows how to access the Word API from VC++ :

http://support.microsoft.com/kb/238393[^]

Use that article to get started with how you can get going with C++ and COM. Once you get that working take a look at this article:

How to: Search for Text in Documents[^]

That article is for .NET but once you''ve got COM access, the method/property names would be the same. So you can just convert that to equivalent C++ code, and that should be what it takes to do what you are trying to do.

Good luck!


Yes, please.
—SA


这篇关于在Word文档中搜索关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆