Solved

Read data from word file...

Posted on 2002-07-12
12
179 Views
Last Modified: 2013-11-20
Hi All,

Here, I want to know how to read the data from any MSWord file using VC++. Is this can be acheived using mfc, automation etc. If so, then please explain how to do aceive this?

Thanking You
Venu
0
Comment
Question by:vgopalji
  • 5
  • 4
12 Comments
 
LVL 4

Expert Comment

by:mblat
ID: 7150383
Most important question - do you have MSWord installed on target machine or not?

If yes the easiest route would be automation described on msdn.microsoft.com.

Thare too many links on a subject to be posted here, but I post one.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dno97ta/html/msoautovc.asp

hope it helps...
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7152072
Hi vgopalji,
Do you need additional information?
-- Dan
0
 

Author Comment

by:vgopalji
ID: 7156292
DanRollins

Thankyou for your response. I need more information regarding accessing/reading data from word file.

venu
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7156444
Hi vgopalji,
Did you check the page that mblat suggested, in particular, did you look at this link?
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q178784
There is a complete example there.

Please describe what you would like to do once the WORD document is open.  Display it? Search for a particular string of text in it?  Modify it and save it?  

Please provide more details.  Thanks!
-- Dan

0
 

Author Comment

by:vgopalji
ID: 7159195
Hi DanRollins,
Thanks for the support. I went through the given link and able to access the word page in my application and able to perform the functionalities such as print the word document, priview the page. But, here I am unable to read the data from the word document.
Here, they provided _Document functions like GetSentences(), GetParagraph() & GetWords(). Can I use these functions to retrieve the data. Please, let me know how to proceede further.
Thank You,
Venu
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 49

Expert Comment

by:DanRollins
ID: 7160222
>> ...Can I use these functions to retrieve the data...
Yes.  But a lot depends upon whaat you need to do.

Please describe what you would like to do once the WORD document is open.  Display it? Search for a particular string of text in it?  Modify it and save it?

-- Dan
0
 

Author Comment

by:vgopalji
ID: 7161368
Hello Dan,

Good.. Here I would like to read and extract the data from word document on to the other storage media or notepad, etc.
Here, I would like to brief my application which is as follows. At present I am working on voice applications, which uses Text-to-Speech(TTS)engine to read out. For the TTS to work it takes a strings/characters/words as the input data. Now I can able to perform the same with HTML/notepad/wordpad data, but it is not the same with Word document, because format is totally different.
So, to acheive this I need to extract the sentences/words from the word document by using your method and later I fed this to my engine.
Hope now  you got my approach. So, please help me how to solve this.

Thanks
Venu
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 100 total points
ID: 7161407
That makes the question much clearer.  Thank you.

There is one very simple solution that I'd like you to consider.  In Word, or any other program, it is possible to select a part of the document and then 'copy' that selected data to the clipboard.  Now even if that data has a lot of formatting or graphic images or tables,... etc, then when you copy it to the clipboard, if you then paste it into say, Notepad, then you end up with only the text part of the document.

I believe it is that text that you want to isolate.  So if you can manipulate Word to select all or part of the document, and then use the SelectionCopy() function, then you can read the text out of the clipboard and if you request the CF_TEXT format, then you will obtain only the text -- and I believe it will be in a form that your text-to-speech programs can handle.

=-=-=-=-=-=-=-
The next alternative that I'd look into is this:  Access the Sentences array of the Document object.  You can cycle through them.  Each of the returned 'items' is a Range object.  You can use the GetText of that object or you can use the Select member and then use the Copy member to get it into the clipboard.

=-=-=-=-=-=-=-=-=-
For 100 points, I cannot write your program for you.  But here is how I would proceed:  I would work with Ms Word, in its Macro editor and play around with the "Word Basic" commands to learn how to iterate through the senetences and/or the words and obtain the text so that it looked exactly as you need it.  You will find that there is a one-to-one relationship between the VBA document functions and the ones that are availabe to your C++ program after you have done the
   #include "msword9.h"
or whatever you use to create the C++ wrapper files for the MsWord objects.  The header file msword9.h is somewhat hard to follow, but the online help in Word (when you are in the VisualBasic editor in Word) is very clear and complete.  The only problem is that it is in VisualBasic for Applications, so you will need to do a sort of translation from one to the other.

Good luck with your project.

-- Dan
0
 

Author Comment

by:vgopalji
ID: 7164687
Thanks Dan,

Now, I am running out of the time. From your response the third solution is looks sound and I would like you to help me in that regard. Regarding points I, am flexible and give you good points. So, tell me now how to continue.

W.r.t this project we alredy started some work which is as suggested by you, so now I would like to continue in the same way by using _Document functions such as GetSenetences(), Paragraphs() and word() etc. Hope I am clear from my side and looking forward favourable reply.

Thank You
Venu
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7165277
>>So, tell me now how to continue
Please re-read my last post.  You will see there some suggestions on how to proceed.  I will not write your program for 100 points, no matter how much time pressure you feel.  Sorry.  If you are having some specific problems, please show the code that is failing and I will  try to analyse it

-- Dan
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 100
deburging in oracle form 12 76
sum13 challenge 24 77
either24  challenge 19 84
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now