473,396 Members | 2,154 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,396 software developers and data experts.

How to scan/parse through Word Document?

Bob
What I want to do is write a program that reads through a
Word Document, finds certain words or sentences I want,
and then paste into an Excel spreadsheet.

I dont know much about C#. But I learned how to use
those COM Interop things. And Im able to write code that
allows me to open existing Word documents and existing
Excel spreadsheets. And I know how to write into
specific columns and rows of the spreadsheet.

But I dont know what functions to use or the code for my
parser to look through the Word Document. Ive found
through the Object Browser some Objects in the
microsoft.office.interop.word assembly that may help.
Some of the members in the Range() object and Selection()
object seem like they may be what Im looking for. But Im
not sure if they are or even how to use them.

Any help would be much appreciated. Thanks.
Nov 15 '05 #1
3 4334
..Find method is probably what you want to use. Here's a good way to start.
Open up a word document and start recording a macro. Then, do whatever you
think you want your program to do. End the macro. Look at the code. It
will have a lot of extra crap in it, but it will give you a good insight
into how Word works..

You can also load the contents into a stream and use Regular Expressions to
parse it....

HTH,

Bill
"Bob" <rf***@hotmail.com> wrote in message
news:05****************************@phx.gbl...
What I want to do is write a program that reads through a
Word Document, finds certain words or sentences I want,
and then paste into an Excel spreadsheet.

I dont know much about C#. But I learned how to use
those COM Interop things. And Im able to write code that
allows me to open existing Word documents and existing
Excel spreadsheets. And I know how to write into
specific columns and rows of the spreadsheet.

But I dont know what functions to use or the code for my
parser to look through the Word Document. Ive found
through the Object Browser some Objects in the
microsoft.office.interop.word assembly that may help.
Some of the members in the Range() object and Selection()
object seem like they may be what Im looking for. But Im
not sure if they are or even how to use them.

Any help would be much appreciated. Thanks.

Nov 15 '05 #2
You can match patterns with WildCards...look in the Find Dialog under More
or Advanced depending on the version you are using. You can use % and a few
other ones...

You can set string s = .Find--whatever
"bob" <rf***@hotmail.com> wrote in message
news:77****************************@phx.gbl...
Oh wow, thats helpful.... Did not know about macro's.
Another problem i can see now is there is no pattern to
what I want to copy over. Is there like a string compare
so after I select a certain word or line I can check to
make sure its what I want?
-----Original Message-----
..Find method is probably what you want to use. Here's

a good way to start.
Open up a word document and start recording a macro.

Then, do whatever you
think you want your program to do. End the macro. Look

at the code. It
will have a lot of extra crap in it, but it will give

you a good insight
into how Word works..

You can also load the contents into a stream and use

Regular Expressions to
parse it....

HTH,

Bill
"Bob" <rf***@hotmail.com> wrote in message
news:05****************************@phx.gbl...
What I want to do is write a program that reads through a Word Document, finds certain words or sentences I want,
and then paste into an Excel spreadsheet.

I dont know much about C#. But I learned how to use
those COM Interop things. And Im able to write code that allows me to open existing Word documents and existing
Excel spreadsheets. And I know how to write into
specific columns and rows of the spreadsheet.

But I dont know what functions to use or the code for my parser to look through the Word Document. Ive found
through the Object Browser some Objects in the
microsoft.office.interop.word assembly that may help.
Some of the members in the Range() object and Selection () object seem like they may be what Im looking for. But Im not sure if they are or even how to use them.

Any help would be much appreciated. Thanks.

.

Nov 15 '05 #3
bob
You've been a lot of help so far... thanks.

one more question which may be kind of dumb. But in my
code i wrote...

_Document document = application.Documents.Open(...etc...)

And from there I can use document.Range(), document.SaveAs
(), document.Words.First.InsertBefore().... etc...

but i cant use the functions under Selection such as
Find.Execute(), MoveUp() ..etc...

so do I have write something like...

Selection select = ?

set that equal to something and then from there use
select.MoveUp() ?

if so what would i set Selection select equal too?

thanks
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John A. Irwin | last post by:
I'm very new to PHP and am trying to figure out how to parse out a variable "HTTP_REFERER". My reason for this is my site was recently "FEATURED" (sic) on a website called FARK.COM. Because of...
3
by: Tom Turner | last post by:
Here's the background on my situation. The question follows --- We have 600 units of mail going from our business to various Post Offices every morning. Every unit is accompanied by a paper...
1
by: Mark | last post by:
We want to allow users to upload a Word document on our site. Is it possible to leverage Norton Antivirus in some way to scan the file AS it's being uploaded? Thanks in advance. Mark
26
by: Charles Law | last post by:
Does anyone have a regex pattern to parse HTML from a stream? I have a well structured file, where each line is of the form <sometag someattribute='attr'>text</sometag> for example <SPAN...
2
by: Mike Fellows | last post by:
Hi, I am trying to parse a word document to get a list of all the bookmarks that are setup within the document I need to be able to parse the bookmarks though without knowing the bookmark...
0
by: sameer | last post by:
Hi all, ..net framwork 1.1 sql server 2000 I have a vb.net winforms application using webservices\ remoting to upload documents\ images to the webserver and i am gong to store them in the sql...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.