can anyone one help me how to write the below code in C#.NET
i am able to create the wordapp and openthe document but further things like compare word document content and not able to.... plz help me
i am able to create the wordapp and openthe document but further things like compare word document content and not able to.... plz help me
Code:
// Create an instance of Word
if (!objWordApp.CreateDispatch("Word.Application"))
{
SendMessage(m_pFRMgr->m_hActiveDlg,WM_TR_READ,0,(LONG)(LPCSTR)m_pFRMgr->m_strErrMsg);
}
objWordApp.SetVisible(FALSE);
objDocs = objWordApp.GetDocuments();
//open the word file
lpDisp = objDocs.Open( COleVariant(strTRFile, VT_BSTR), covFalse, covFalse,covFalse,covOptional,covOptional,covFalse,covOptional,covOptional,covOptional);
if(lpDisp == NULL)
{
if(objWordApp)
objWordApp.Quit(covFalse, covFalse, covFalse);
}
objDoc.AttachDispatch(lpDisp);
//Get word Source Doc ID:
objWords = objDoc.GetWords();
int sizeWords = objWords.GetCount();
CString strDocID;
bool bSource = false;
for(int cntWords=1; cntWords <= sizeWords; cntWords++)
{
Range objRange1;
CString strWord;
objRange1= objWords.Item(cntWords);
strWord = objRange1.GetText();
strWord.TrimLeft();
strWord.TrimRight();
if(strWord.CompareNoCase("Time") == 0)
break;
if(bSource && strWord.CompareNoCase(":") != 0)
strDocID += strWord;
}
Comment