Reading From Word Document

How can I open and read a Microsoft Word Document?
mh149Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lbkCommented:
You can either use OLE (Reference Office, word object library):

Word.documents.open

etc etc

or you can use VBA, but then you would have to initiate execution in word (There is ways around it, but complicated)

More info = more points

L.K.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JagarCommented:
use automation.  Put a reference in to Work Type Library.  Then you can do declare a variable of Word.Application.  Then there is all sorts of properties that you can look through to do whatever you want with the document.  You can use YourVariable.Range.FormattedText and this will return all of the text in the document.  Before you do this you will have to do YourVariable.Open blahfilename

0
ESICommented:
In your class :

Private wd As Word.Application     ' Handle on Word application
(..)

' Create a Word instance
If wd Is Nothing Then
    Set wd = CreateObject("word.application")
    If Not wd Is Nothing Then
        wd.Visible = False ' or True
        wd.DisplayAlerts = wdAlertsNone ' or 1
    Else
        '- Word error ?
        (...)
    End If
End If

and to close it :

If Not wd Is Nothing Then
   Call wd.Quit(wdDoNotSaveChanges)
   Set wd = Nothing
End If


REM :
In the Project -> References, add a ref. to Microssoft Word 8.0 Object Library, so you can access to the constants, aso and define the wd var of Word.Application type (Early binding) instead of the more generic & less efficient Object type (Late binding)

Hope it helps

CU around
Emmanuel

0
mh149Author Commented:
lbk - that amount of info is not worth much more than a comment...
would have given it to ESI has he proposed the answer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.