Microsoft word document parsing using in C#.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SowAruna
    New Member
    • Oct 2012
    • 1

    Microsoft word document parsing using in C#.net

    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
    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;
    }
    Last edited by Meetee; Oct 11 '12, 08:51 AM. Reason: Use code tags <code/> around your code
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Compare it how? What are you trying to parse for? Without a description of these things, there's not much we can help with.

    Comment

    Working...