Programmatically activating drawing functions

S

szcz.andrew

Hi All,

I'm trying to perform the equivalent of 'pressing' a drawing button
(line, circle, square, group, ungroup, etc.) in MS Word 2000+ (needs
to work with 2007 as well). I'm having problems figuring out how to
do this - most other functions I was able to simply run a macro or
perform using the appropriate VBA object. With the drawing functions,
I am having problems finding equivalent functionality in VBA or in the
macros - can anyone help?

Cheers,
Andrew
 
J

JGlowski

You can add a shape to a word doc using VBA with the code:
ActiveDocument.Shapes.AddShape(msoShapeOval, 369#, 450#, 72#, 72#).Select

The previous line puts an oval at location 369,450 with it selected, ready
to manipulate. Look up the AddShape method in VBA for additional info.

If you want to emulate clicking a button (or any other menu item) use this
code:
CommandBars(NameofMenuORToolbar).Controls(Indexofmenuitem).Execute

The following code emulates clicking the Oval button in the Basic Shapes menu
CommandBars("Basic Shapes").Controls(9).Execute
 

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