Change color on specific type of shapes

J

jmlight0

I am trying to write some VBA code to work on Visio 2003 that runs through
all the shapes on a page and changes the color on all the circles it finds
based on the text caption of those circles. To be more specific, I want to
grey out the backcolor on all circle shapes on a page that have the word
"completed" as the text caption for the shape. That way, someone looking at
the Visio chart will see all completed tasks in a neutral, greyed out color.
I would appreciate it if someone could give me a code sample to get me
started. Thanks in advance.
 
J

jmlight0

Thank you, but the color change was not the problem. My problem (the thing I
couldn't figure out how to do) was to identify the circles. I could not find
a property in the shape object that says "this is a circle" or "this is a
triangle"... . If someone could tell me how to identify what the shape is,
then it will get me started. Thanks.
 
J

jmlight0

Thank you. That is getting much closer to what I neded (I simplified my
problem quite a bit to keep the length of my question
manageable--specifically, I left out the part about looking up each shape
based on its text title in a remote SQL database to determine if it is
"completed"). In any event, this should get me started. One last question.
Since noone mentioned a specific property that tells Visio what the shape is,
am I to assume that Visio does not store some identifier that differentiates
a circle from a triangle or a connector line? How in the world does it know
the geometry of a shape if it doesn't store what the shape is??? Is there no
way to link an instance of a shape to the template class that it was created
from? Thanks.
 
M

Mark Nelson [MS]

Most add-ons put an identifier into the shapes so that they can be tracked.
Visio only has the name of the master shape and the UniqueID to identify it
definitively. There is no simple way to ask what a shape looks like, and
that is generally not a good way to differentiate shapes.

If you want to tell a 1-D shape from a 2-D shape, Visio provides a
Shape.OneD property. This really reports whether the shape behaves as a 1-D
or 2-D shape, and it is possible for a two dimensional shape to behave as
1-D. If you want to identify connectors (as opposed to lines), you could
check the ObjType cell of the shape to see if it is 2.

Beyond this you should consider adding a User-defined cell to track what
kind of shape you have.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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