?
Solved

Programatically parsing a Word doucment using C# and COM

Posted on 2004-10-13
9
Medium Priority
?
165 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

771 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