Solved

Programatically parsing a Word doucment using C# and COM

Posted on 2004-10-13
9
163 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
Industry Leaders: 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!

 

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
length of the password hash sha1:64000 to set sql field property. 13 88
Need help with a query 14 39
Visual C# Windows Project - Clone Form 4 24
Adjust the codes 3 33
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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