Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Some of the pre-installed shapes that come with Visio 2007 have options. For example, if I insert an SPDT from the Electrical Engineering › Switches and Relays shapes page into my drawing, I can right-click on it and select “Set Switch Position”.

How can I add such functionality to my own shapes?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I'm not sure how familiar you are with Visio, but under any shape is something called a shapesheet. The shapesheet is basically a spreadsheet where each cell is directing Visio in rendering your shape (or otherwise holding data).

To get there, I believe you have to enable developer mode in Visio, then you can right click a shape and select the shapesheet window. I think it's also in the Window dropdown/ribbon.

So anyway, once you get into the shapesheet you can see items like the shape's width, height, etc... And if you select a cell with say the width, you'll probably just see values, but with an = sign in front of it. So instead of a straight-up value for width, it's actually a formula. Change the Height formula to be =Width/2, and you'll see that as you adjust the width, the height maintains being half the width.

So now to get closer to answering your question, my guess is that the shape you're referring to uses shapesheet trickery to do what it does. There are many different types of data in the shapesheet, and it's usually broken out by sections. The section that defines the right-click menu for a shape is called the User Actions section. If you view the shapesheet for the switch shape you'll probably find an action cell that has a formula that changes some other cell's value using SetF or something similar. So the shape is probably set up such that by toggling a single cell's value, it changes the way it looks.

So to set your own shape up like that, you have to do something similar, basically creating a user cell that holds the selected option. Then have all your other formulae set up to read that one cell. Then your action cell sets the option when it's clicked.

Another thing you can do is use VBA in Visio to respond to action clicks (using a different formula - callthis), but in that case your VBA is going to be modifying shapesheet values and formulae, just using a different language, essentially.

There is a wealth of information online on how to do all this stuff, but the one word you need to know for your searching is: ShapeSheet.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.