select from sub-shape

Started by david, September 10, 2009, 04:36:14 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

david

i have a problem i hope you can help me with.

i built a shape with actions menu (the pop-up appears by right click of the mouse).  whenever you click something in the action menu, it runs a function.  in the function i need to know which shape was clicked so i wrote "set shape = ActiveWindow.Selection(1)".  but it doesn't work if the shape was in a group.  in this case ActiveWindow.Selection.count=0 (don't know why...).

how can i find the relevant shape if it was clicked from inside the group?

thanks
David

vojo

cannot run VBA from a cell directly...have to call a macro and pass info to it.  This does not solve the selection problem since the group is selected not subshape...so macro would have traverse group to find subshape then act on it.

Also, assuming you want to try to use DOCMDs, they only work for the shape selected...you cant select 1 shape or subshape, do a DOCMD that affects another shape.

Assuming you wanted stay clear of VB and wanted to affect some given subshape, you could do the following:
   1. define 3 user cells in each subshape
          - 1 for ID of subshape (your name or shape ID)
          - 1 for ID of subshape to act
          - 1 for action/value (can have more cells if you want to separate it all)
   2. define some user cells at group level
   3. have action/value cell(s) in subshape reference group user cells.
   4. define user cell in subshape for execution
          - in it have something like the following:
                 if (subshape_id = subshape_to_act, perform action using value)
          - be forewarned, this will get complicated if there are several actions for given subshape or several values
   5. at group level, define action
          - something like
                setf(getref(user.action/value),the action and/or value to perform)+setf(getref(user.act_subshape),subshape to should act)

so when you select the action at group level, the following will happen
   1. action cell will set the value in the group level action/value cell
   2. action cell will set the subshape id that should act on data in the the activate subshape cell
   3. each subshape will look at its subshape to act cell (which references the group activate subshape cell)
   4. each subshape will compare to its shape ID
   5. only the subshape that has the matchng ID will use the action/value information (they also ref group level cells)

Probably need to work the corner cases to ensure proper operation

This is tedious but does work on things like having a variable drop down list for custom properties (ie subset the properties to present to screen to get aorund the 25 limit).
   
   

Visio Guy

#2
There is some more information on selections via programming here: Detect Sub-selected Shapes Programmatically.

There is a property called IterationMode that will help you out. The article contains some info on it, and you can also search for it in the Visio SDK help or developer help that comes with Visio.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010