473,387 Members | 1,638 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
Expand|Select|Wrap|Line Numbers
  1. // Create an instance of Word
  2. if (!objWordApp.CreateDispatch("Word.Application")) 
  3. {
  4. SendMessage(m_pFRMgr->m_hActiveDlg,WM_TR_READ,0,(LONG)(LPCSTR)m_pFRMgr->m_strErrMsg);
  5. }
  6. objWordApp.SetVisible(FALSE);
  7. objDocs = objWordApp.GetDocuments();
  8. //open the word file
  9. lpDisp = objDocs.Open( COleVariant(strTRFile, VT_BSTR), covFalse,                    covFalse,covFalse,covOptional,covOptional,covFalse,covOptional,covOptional,covOptional);
  10. if(lpDisp == NULL)
  11. {
  12. if(objWordApp)
  13. objWordApp.Quit(covFalse, covFalse, covFalse);
  14. }
  15. objDoc.AttachDispatch(lpDisp);
  16. //Get word Source Doc ID: 
  17. objWords = objDoc.GetWords();
  18. int sizeWords = objWords.GetCount();
  19. CString strDocID;
  20. bool bSource = false;
  21. for(int cntWords=1; cntWords <= sizeWords; cntWords++)
  22. {
  23. Range objRange1;
  24. CString strWord;
  25. objRange1= objWords.Item(cntWords);
  26. strWord = objRange1.GetText();
  27. strWord.TrimLeft();
  28. strWord.TrimRight();
  29. if(strWord.CompareNoCase("Time") == 0)
  30. break;
  31. if(bSource && strWord.CompareNoCase(":") != 0)
  32. strDocID += strWord;
  33. }
Oct 11 '12 #1
1 3146
Rabbit
12,516 Expert Mod 8TB
Compare it how? What are you trying to parse for? Without a description of these things, there's not much we can help with.
Oct 11 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Zeke | last post by:
I'm using the following code to create word document but the problem is if you go to task manager you'll see a WINWORD.EXE process is running but not the application, here is the code: ...
2
by: terry | last post by:
I'm trying to figure out how open a microsoft word document from within an asp.net application. There is information in the web form that I need to merge with the opened document. I can't seem to...
1
by: JSL | last post by:
How to insert images into a Microsoft Word document using VB.NET?? my code: Public Function PictureReport() (it doesn't work!!!) On Error Resume Next Dim oDoc As Word.Document Dim range As...
1
by: mhsasono | last post by:
Hi all, Has anybody experienced with CrystalReport? My question is: Does CrystalReport have capability to print the Microsoft Word document? Reason: I want to know CrystalReport capability...
2
by: gusa992000 | last post by:
Hello I am trying the following problem: A web app in jsp and java has to open a microsoft word document directly in the browser. This part is easy and i have done it. The user then can...
1
by: Jai | last post by:
Hi, Is it possibe to update a word document template using ASP.NET 2.0 Example: This is a word template. Employee Name: <Name> Employee No: <EmpNo>
2
by: jeevalokesh | last post by:
Hi I'm new to forms.could any one tell me how to call the word document by using forms.
2
by: beemomo | last post by:
I have some invoice data on an MS Access form, and I wish to export the data into Microsoft Word document, can anyone help me please? Many thanks..
1
by: devsri79 | last post by:
How to find the word in the word document by using the c#
4
by: =?Utf-8?B?QXJ0?= | last post by:
Hello, I saw this posting and it is the closest place to ask this question. I am simply trying to create a Word document from a VB application I am wrting with Visual Studio 2005. I cut a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.