• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

Read data from word file...

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
vgopalji
Asked:
vgopalji
  • 5
  • 4
1 Solution
 
mblatCommented:
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
 
DanRollinsCommented:
Hi vgopalji,
Do you need additional information?
-- Dan
0
 
vgopaljiAuthor Commented:
DanRollins

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

venu
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
DanRollinsCommented:
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
 
vgopaljiAuthor Commented:
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
 
DanRollinsCommented:
>> ...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
 
vgopaljiAuthor Commented:
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
 
DanRollinsCommented:
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
 
vgopaljiAuthor Commented:
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
 
DanRollinsCommented:
>>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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now