How to invoke MS Word drawing objects programatically ?

L

Linny

Hi,
I have recently started programming in the Windows Environment.
My application(Developed in C++) needs to draw the basic
shapes(lines,polygons etc.) that are provided by MS Word 2002,
programatically rather than drawing them by selection from the Drawing
tool bar that Word provides.
The shapes should be placed on the currently active Word document(or
any other MS office application window in focus), when invoked through
the application.


Is this possible and if so,is there any API's which we can use for
interacting with the drawing objects ?


Linvin
 
C

Cindy M -WordMVP-

Hi Linny,

If you're automating Word (or another Office program) then yes, you
should be able to create drawing objects. The "API" would be the object
model of the application you're automating; the information is in the
VBA Help files for that application.

A good way to get started is to record using a drawing tool in a macro,
to find out which objects, methods and properties are involved. You
can't actually USE the code the macro recorder produces; you'll need to
edit and adapt it. But it can give you a good start in the object model.

Do note, however, that using the Shapes collection in Word has numerous
pitfalls and "gotchas".
I have recently started programming in the Windows Environment.
My application(Developed in C++) needs to draw the basic
shapes(lines,polygons etc.) that are provided by MS Word 2002,
programatically rather than drawing them by selection from the Drawing
tool bar that Word provides.
The shapes should be placed on the currently active Word document(or
any other MS office application window in focus), when invoked through
the application.


Is this possible and if so,is there any API's which we can use for
interacting with the drawing objects ?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
L

Linny

Hi,
I am now facing a problem of passing parameters to the Invoke function
of the IDispatch interface.
As I want to draw a rectangle shape I use GetIDsOfNames for AddShape
function of Shapes interface in the Word Object Model.
The type of shape in the VB macro that was gerated is
msoShapeRectangle.

As I am writing a C++ ( not MFC ) application how do I pass parameters
such as type(rectangle), x-y co-ordinates,height-width of the shape to
the Invoke function

-Linny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top