954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C++ AddIns 4 MS-Word

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.

Tamir
Newbie Poster
14 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

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

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 

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.

Tamir
Newbie Poster
14 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

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.

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 

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

Tamir
Newbie Poster
14 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

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.

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 

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

Tamir
Newbie Poster
14 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

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.

Ancient Dragon
Retired & Loving It
Team Colleague
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

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.

Tamir
Newbie Poster
14 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

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.

Ancient Dragon
Retired & Loving It
Team Colleague
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

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

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

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

Tamir
Newbie Poster
14 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

Ah...

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

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

Tamir
Newbie Poster
14 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

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

Ancient Dragon
Retired & Loving It
Team Colleague
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

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.

Tamir
Newbie Poster
14 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

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

Tamir
Newbie Poster
14 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

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 :(

Tamir
Newbie Poster
14 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 
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???

Ancient Dragon
Retired & Loving It
Team Colleague
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

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.

Tamir
Newbie Poster
14 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You