Changing color of shape with VBA code...

T

The Rookie

I would like to change the color of a shape with VBA code. How can this be
done? code examples?

In the long run i would like to be able to do this using data from a
database, controlled by the VBA code. Thanks!
 
T

the rookie

Can i target it to specific shapes? As in the long run i need to change the
color programmatically through vb code depending on data in a database. (if
you have any thoughts on that, that would be great!)

For a start id like to link one single shape through to a database and
depending upon what the value is in the database (probably have to be 1, 2,
3, etc) id like to change the color of the shape.

thanks!
 
T

the rookie

Also, I put in that code and it didnt do anything. Dont i put this in the
VBA code behind for Visio (i have limited experience with Visio but do know
my way around vb.net programming environment.)
 
J

John Marshall, MVP

The code snippet was a section of VBA code. ShpObj is a pointer to a shape.
So before the code snippet can be used you must establish ShpObj. The
following code snippet loops through the shapes on a page and prints their
names to the immediate window (This code is run in the VBA environment).

For ShpNo = 1 To ActivePage.Shapes.Count
Set shpObj = ActivePage.Shapes(ShpNo)
Debug.Print shpObj.Name
Next ShpNo

For more examples take a look at www.mvps.org/visio/VBA.htm

John... Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples? http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm
 

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