Hi all,

I programed an addin which works with ms-word. I wish to parse the text of an active ms-word document and to replase some of its words and chars.

How can I retrieve the documents text? How can I write text into the document?
AND how can I replace text in the document.
Moreover,
can I get a text with specific format; as example, all the text in the document which is in Bold or Italic format or alternatively all the text which is font "Courier New" ???

I have searced for help all over the internet with no success.
Pleas help me with that, Im having a hell of a tim with it.

I would personally go for a Visual Basic Macro or use Visual Basic to write the addin. But maybe this will help.

Hi, thanks for your reply.
Regarding your suggesttion about vb,...
Im a c/cpp programer and i dont know anything about vb.
Anyway, I allready read this link and it doesent help me because it is related to vc6 and i work with .net environment. Moreover, they do not retrieve text from the ms-document.:sad:

However thanks for trying.
Any help will be appreciated.
Best regards.

It has been a long time since I wrote a macro, but if I remember correctly,
ThisDocument.Text gives you the text in the current document. Compile and see.

Is it in a cpp format?
if true, how can i define this variable "ThisDocument".

Oh I just read the part where you say that you are working in the .NET environment. ThisDocument is a VBA thing I guess. Don't know if it is possible to use in the .NET environment. Will take some time to find that out. Sorry about that.

Yes, and I program in vc++, ... all the code that i wrote is in vc++.
I hope fore more help :)

maybe this will help. But this will be a great deal easier if you learn to use VB.NET -- you can mix and match VC++.net and VB.net functions.

This link is very good and it helps me,
but there is nothing in it which relats to
retrieving the documents text, writing text into the document or
replacing text in the document.
Moreover, there is no mention regarding a way to
get a text with specific format; as example, all the text in the document which is in Bold or Italic format or alternatively all the text which is in "Courier New" font.

However, the link is very helpfull, and so is your reply,
but I hope to get something more specific :)
Best reggards.

I think you should research Microsoft Office Automation. This is not something that you can do in one evening, requires quite a bit of reading and studying. I don't think you will find easy answers to your questions. You may also want to search www.amazon.com for related books on M$ Office Automation.

Member Avatar for iamthwee

Is there any particular reason why you want to do it with ms word?

You can pull off a cheap and dirty way to change the font and style by piping your output to a .html file .... by using <html> </html> code tags?

It must be compliant with all office tools including power point excel etc.
And it must be with an addin.

Member Avatar for iamthwee

Ah...

Is there anybody how can help me more?
It seems like a big problem ..

>>It seems like a big problem

Yes, it is a lot more complex than what one might expect, and you probably won't find anybody willing to do all that for free. There is no easy solution to what you want. You are going to have to bite the bullet and do your own research.

you will also find some information at www.codeproject.com. When you get there, enter "Office Automation" in their search engine and it will give you links to a few articles and examples. like this one.

Hi again,
regarding the same ms-word addin which im developing,
I have a problem with rename, i.e. ...
#import "libid:00020905-0000-0000-C000-000000000046" raw_interfaces_only
rename( "ExitWindows", "WordExitWindows" )
//Although renaming "ExitWindows", I get lots of errors which are located at msword.tlh.

some of the errors are:
error c2497: 'Word::Tasks::ExitWindows': 'implementation_key' can only be applied to function declarations.

I dont know what to do with it.
Any help will be appreciated.
Regards.

Does anybody know if BEGIN_MESSAGE_MAP can/cant work within an ATL COM addIn. I cant use it in CConnect object ???

Does anybody knows what comes instead of MESSAGE_MAPs within an addIn (beause it seems like message maps are not acceptables with addIns) ??
or may be no one is interested in this thread any more ...
I feel like im the only one how is interested in this thread :(

Does anybody knows what comes instead of MESSAGE_MAPs within an addIn (beause it seems like message maps are not acceptables with addIns) ??
or may be no one is interested in this thread any more ...
I feel like im the only one how is interested in this thread :(

No replies doesn't mean nobody is interested -- it means nobody knows the answer to your question. When you start out by saying "Does anybody knows ..." more than likely the slience means No and I don't have time to do your research for you.

BEGIN_MESSAGE_MAP is an MFC thingy -- why would you expect to be able to use it in non-MFC projects???

No interest means no comments, no one did or tryed to do something like that OR no one is facing the same problems and OR no one has a comment or timee to write a comment regarding the issue. -- there is no discution regarding the thread
- the problem is mine but Im here to share it with those how have similar problems - thats what forums are for.
(its not for those how search for work and payments)
Best regards.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.