Solved

Programatically parsing a Word doucment using C# and COM

Posted on 2004-10-13
9
160 Views
Last Modified: 2010-04-15
Hello,

I am trying to build a C# Windows application (using COM) and using an openFileDialog control; point to an MS Word document, parse the Word document, add the parsed contents to an array, extract the items in the array that I need using regular expression comparisons, and build an Excel document for the output.  The issue I am having is actually opening the MS Word document and extracting the text.  Any help is appreciated.

Tom
0
Comment
Question by:Thomas_H_68
  • 4
  • 3
9 Comments
 
LVL 6

Expert Comment

by:KingDumbNo
ID: 12300337
Hi Tom.
Take a look at this question:
http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_20389638.html
and particularly the last comment.

The .NET framework and COM do not play well together.

Regards,
Emory
0
 

Author Comment

by:Thomas_H_68
ID: 12300541
Understood - I don't need speed and realize the depth of the question.  I am basically attempting proof of concept so VBA is not an option.  I will try to modify the example given and will update this question based upon the outcome.

Thank you,
Tom
0
 
LVL 6

Expert Comment

by:KingDumbNo
ID: 12300634
I don't understand the "VBA is not an option" phrase.  VB 6.0 or VBA _is_ the way to go, imho.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Thomas_H_68
ID: 12300692
The idea is to do this completely within a C# windows application with all internal operations transparent to the user - it is a proof of concept.  Are you suggesting accessing a VBA object through the C# windows app?

Tom
0
 
LVL 6

Expert Comment

by:KingDumbNo
ID: 12301084
It is most certainly doable in C#, just not as easy as it is from a VB 6.0 application believe it or not.  VBA doesn't make sense if this is to be more or less transparent to the user.  If you do end up going that route then I'd say start the application by the user opening an Excel template.  I'm not sure of the regex ability from VBA though.  Sorry I don't have the time to go into detail on all of the steps necessary.  I see this was your first question ever on EE.  If you have unlimited question points then I suggest opening a new question with this title:
"Need help accessing text in a Word document and writing to Excel, using C# is a requirement"
One thing more to make clear is that this is transparent to the user.  Does the user select the file?

Again, sorry I'm not much help.  Asking the new question may get you more coverage.

Regards,
Emory
0
 

Author Comment

by:Thomas_H_68
ID: 12301525
Yes, the ability for the user to select the Word doc is a requirement.  I have the application to the point where it opens the user selected Word doc file (this open file is not visible to the user nor should it be) so the next step is iterating through the file extracting the text.

Tom
0
 
LVL 6

Accepted Solution

by:
KingDumbNo earned 500 total points
ID: 12301978
Sounds like you're close.  I would suggest opening up Word, go into VBA (Alt+F11) and looking at the object model for an idea of what is available.  Just keep in mind accessing the methods are a little different.  (E.g., get_ added to the beginning of some methods).  I won't be checking this anymore today, so good luck.  I check the progress tomorrow.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
install app on other machine 13 32
Iterate a dictionnary to change values 4 53
About delegates in c sharp 3 35
C# Json POSt to Rest API 4 37
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now