Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting Comments from A Word component.

Status
Not open for further replies.

Kapadia

Programmer
Feb 28, 2001
21
IN
Hi,
I am working on a ATL Component that loads a Microsoft Word document and extracts all the text from it. As far as extracting the text is concerned it works fine. But when I extract text from the Comments that one gives in the word document, I can extract the number of comments, Author who made the comments and other relevant stuff. But I cann't extract the text in the Comments.
I am using msword9 component.
Code snippet is as follows:


theDoc = theDocuments.Open(vFileName,vTrue, vTrue, vOptional, vOptional,vOptional,vOptional,vOptional, vOptional,vOptional,vOptional,vOptional);

// Set the Readonly property of the Document to True,
// so as to avoid any change.
theDoc.SetReadOnlyRecommended(TRUE);

// Set the range of the document from Start point to End point
theRange = theDoc.Range(vStart, vEnd);

theComments = theRange.GetComments();
int iCommentCounter = theComments.GetCount();
for(int index = 0 ;index < iCommentCounter;index++)
{
CString str = theComments.GetShowBy();
theComment = theComments.Item(index);
//Fails, this should return me a single comment object of type LPDISPATCH
It gives : &quot;Unhandled Exception (Kernel32.dll):0xE06D7363: Microsoft C++ exception

str = theComment.GetAuthor();
int iValue = theComment.GetIndex(); Range objRange = theComment.GetRange();
str = objRange.GetText();
MessageBox(NULL,(LPCTSTR)str,&quot;Comments Made&quot;,MB_OK);
}


Can someone help my case. Thanks in advance.
Hemant
 
Are you sure theese two lines are in the correct order?
CString str = theComments.GetShowBy();
theComment = theComments.Item(index); John Fill
1c.bmp


ivfmd@mail.md
 
Hi JohnFill,
Thanks for the reply but the actual problem was with the for loop. The Index Value in VB for every for loop seems to begin with the 1 and not with 0.
Since the Word object model is built in VB the VC Compiler Raised Exception when a call was made. And there seemed to be the actual problem
Any way, thanks a lot.
Hemant.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top