Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Read data from word file...

Posted on 2002-07-12
12
Medium Priority
?
190 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
[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
  • 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
Technology Partners: 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!

 
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
 
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 300 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

604 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