开发者

How to read MS Word documents using MFC?

I'm working on a project using VC++/MFC and I need to read data from Word documents. I've Googled, but can't find any viable solutions开发者_如何学Go. How can I get started in this MFC? Any help would be appreciated!

UPDATE: Information I can find on the MS support site and Google is really out-of-date, and I need work with on Word 2003 or 2007.


You may want to consider using the Word Automation Class for VC++/MFC, which is based on the Microsoft Excel Automation Class (a port of AutoXL in the Excel 97 Developer's Kit). It should work for all versions of MS Word (2003/2007 included).


You can use OLE automation to talk directly to ms word: http://support.microsoft.com/kb/196776

Though this may not be a viable solution because word must be installed.


One challenge here is to read the formatting information, read test inside a Table etc.. If it were plain stream reading, it would have been much simpler.

What I did in one of my projects was to define bookmarks and read the data in the bookmark. That way I didn't have to worry about the layout in the document. However, for this to work, your word document should be prepared keeping this in mind. Not any generic word document can be read like this.

In my case it was an application form, so my task was simple as I was the one providing the word document for users to fill in data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜