?
Solved

Programatically parsing a Word doucment using C# and COM

Posted on 2004-10-13
9
Medium Priority
?
167 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
7 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

840 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