Shape.get_Section

M

Mike

Hi,

I am new to developing Visio add-ins. I would like to be able to add a
context menu to a particular shape. It appears that I need to add it to the
"Action" section of the shape. Can anyone tell me what the index is of the
"Action" section for the method Shape.get_Section(short Index)? It would
probably be even better if you could tell me how to check to see if the
section exists.

Thanks for your help in advance.
 
M

Mike

Found it: Visio.VisSectionIndices.visSectionAction

Now, how do I add the details of a new row to the action section?
 
S

SteveM

Found it: Visio.VisSectionIndices.visSectionAction

Now, how do I add the details of a new row to the action section?

Mike,

Right Click in the Section and add a row.

There are other posters on this site much more knowledgeable than I.
But I do not think there is a get Section Method associated with a
Shape object. You are correct in assuming that the Action Section is
associated with a Shape menu. But the easiest and most elegant way to
create a Shape menu is with Actions and Smart Tags.

Rows of the Actions Section are connected to rows of the smart tags
Section by a common Tag name. If you add those two Sections to a
Shape Sheet you will see their configurations. A couple of good
places to find some sample code are managed by some guys who support
this site. One is the Visio Guy and his page link of interest for you
would be this:

http://www.visguy.com/Shapes/

And another good site with sample code can be found on this site
maintained by Visio MVPs:

http://visio.mvps.org/

If you meander around the VBA information and Shape Sheet Development
links, there is a good chance you will find some routines that you can
use as a baseline for your design concept. Both sites have links to
other developers as points of departure for more information.

Good luck,

SteveM
 
A

Al Edlund

you might check the visio sdk (shape right mouse action) for some example
code on how to make it happen.
al
 
M

Mike

I appreciate the recommendation.

Correct me if I'm wrong but my application is a Visio add-in and I don't see
any simple way to add a context menu item to an existing shape such as the
"Rack" shape.

I looked at the office furniture application and it appears to be hosted in
it's own application using the ActiveX control for Visio.

I created a method that adds a QUEUEMARKEREVENT to the action section of a
shape. But it appears that I have to add it on the ShapeAdded event every
time which doesn't seem right. Can I add it to the MasterShape? Is there an
event I can listen for that lets me know when the shape has been loaded into
the application such as the "Rack" shape?
 
S

SteveM

I appreciate the recommendation.

Correct me if I'm wrong but my application is a Visio add-in and I don't see
any simple way to add a context menu item to an existing shape such as the
"Rack" shape.

I looked at the office furniture application and it appears to be hosted in
it's own application using the ActiveX control for Visio.

I created a method that adds a QUEUEMARKEREVENT to the action section of a
shape. But it appears that I have to add it on the ShapeAdded event every
time which doesn't seem right. Can I add it to the MasterShape? Is there an
event I can listen for that lets me know when the shape has been loaded into
the application such as the "Rack" shape?

I'm pretty new to Visio but I do optimization modeling using a model
management system's Object Library. However it would be very
difficult to develop a model without building a prototype with the
native standalone system first. It looks like you're in the same boat
trying to code up modifications to Visio shapes without being able to
iterate back and forth as you develop your solution. Seems like it
would be mowing your lawn with a set of tweezers.

I'm assuming that you're working on a commercial project, and given
the manpower cost to modify shapes that way, it would be a lot easier
to just go out and buy Visio and then use that to mod the master
shapes of the add-in stencils. That little workaround would also save
you a lot of headaches.

SteveM
 
M

Mike

Steve,

That's exactly the path that I've taken. I have figured it out.

Basically after the document loads, I iterate over all of the master shapes
that are loaded checking to see if the target shape exists in any of the
stencils loaded. Then if I find any, I add the QUEUEMARKEREVENT to the
Action section. This ensures that any new shapes that get added to the
document will have the action associated with it. Next, I iterate
recursively over all of the shapes in the existing document and again if the
target shape exists I add the QUEUEMARKEREVENT to the Action section. It
seems like a lot of work but it is working.

I would be more than happy to share the code if you run into the same
situation. The product is commercial, but this piece of code is not
proprietary. Just what happens within the added context menu ;)
 
D

David Parker

You may wish to consider amending the Master shape in the document stencil,
then all of the instances should inherit the changes.
Far easier than iterating all of the shapes in the document.
One note is that you edit the Master shape by using :

dupMaster = docMaster.Open
....edit dupMaster
dupMaster.Close

It is not normal to edit the docked stencils as they are usually read-only,
however you can listen to the MasterAdded event of your document to check if
it needs amending as above.
 

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