none
MS word parser RRS feed

  • Question

  • Hello,

    I  have requirement to read the content of ms word doc/docx file for table content, is there any sample code/project in VC++? How do i go about MS automation in VC++ Thanks

    Sunday, November 20, 2011 1:30 PM

Answers

  • There are much, much fewer examples of C++ Word automation compared to Visual Basic and C#.

    There are several ways of doing it.  The way I do it is like this http://www.codeproject.com/KB/office/MSOfficeAuto.aspx. You'd need to get a series of IDispatch pointers, starting with one for the document, which you'd get by querying the Running Object Table. Then get an IDispatch for the range of that document. Depending on how you can identify you your text/table cells, you may then get an IDispatch for the range's 'find' property, and use that to get a narrower range. Or, you may otherwise specify a narrower range. Ultimately you'll end up with an IDispatch pointer for the range that only represents the area of the document you want, and can retrieve its 'text' property.

    (If you don't already know, a 'range' specifies an area of a document).

    • Marked as answer by Bruce Song Monday, December 5, 2011 10:13 AM
    Sunday, November 20, 2011 8:23 PM