views:

244

answers:

3

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. 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.

+3  A: 

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.

Byron Whitlock
i'll check that.Thanks.
SpawnCxy
+3  A: 

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).

Otaku
Thanks for the nice resource,it helps a lot.
SpawnCxy
+3  A: 

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.

Srikanth Venugopalan
That's really a point,i stuck on this problem at the moment.And I'm trying to find the function to handle it in the Word Automation Class mentioned by Otaku.
SpawnCxy