sowbhagya aruna

sowbhagya aruna

  • NA
  • 3
  • 1.9k

How to read the word content by string wise

Oct 11 2012 7:49 AM
How to read the word content by string wise i am able to open the doc but not able to read and comapre the string by string content plz help


// 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;
       
       
     }

Answers (2)