Visio Guy

Visio Discussions => Programming & Code => Topic started by: DM2 on January 05, 2012, 12:30:01 AM

Title: Macro Not working on Grouped Shapes
Post by: DM2 on January 05, 2012, 12:30:01 AM
I want to create a P&ID symbol of a valve.  Symbol consists of two triangle shapes.  The idea is that if you double click on one of the triangle shapes, the fill color will change.  If it's white, it would change to black, and if it's black, change to white.

As long as the two shapes aren't grouped, the macro works fine.  when I group them it no longer works...what am i missing here?
Title: Re: Macro Not working on Grouped Shapes
Post by: aledlund on January 05, 2012, 01:30:59 AM
you might check this out (group behaviour)
http://www.visguy.com/2009/10/13/getting-a-handle-on-selecting-and-subselecting-visio-shapes/
al
Title: Re: Macro Not working on Grouped Shapes
Post by: vojo on January 05, 2012, 02:07:09 PM
1.   You dont need a macro to do that
          - Open up shape sheet
          - Create a user.cell called   user.switch
          - in eventdblclk cell, set it to     setf(getref(user.switch), if (user.switch =1, 0, 1))
          - in fillforegnd cell, set it to    guard(if (user.switch, RGB(0,0,0), RGB(255,255,255)))
      What this does is that when you double click the shape, the user.switch cell flips.    The fillforegnd cell watches the user.switch and decides on color to use
      (if you dont want to use double click....can also do actions to do this)

2.   when you select, you are select the group first...to do what you want you need to do the following
          - At group level, right click group....format ==> behavior....  lower right set to either members first
          - For each shape in the group, if you really want to do this via some macro, then format ==> behavior....action set to the macro you want

Good luck
Title: Re: Macro Not working on Grouped Shapes
Post by: DM2 on January 06, 2012, 03:55:27 AM
This took me a little bit but I think I understand.

Now, If I want to build some shapes and then make them a stencil, do I need to worry about them still functioning after i've created the stencil?
Title: Re: Macro Not working on Grouped Shapes
Post by: Yacine on January 06, 2012, 09:30:16 AM
with vojo's shapesheet solution, the behaviour will be kept we the shape. So it will work also when droped out of a stencil.
If you make a macro driven solution, you need to make sure that the macro is loaded when using the shape, so store the macro in the stencil itself.
Browser ID: smf (is_webkit)
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 1: index+Modifications.english (default).
Style sheets: 0: .
Hooks called: 53 (show)
Files included: 25 - 922KB. (show)
Memory used: 771KB.
Tokens: post-login.
Cache hits: 7: 0.00113s for 22,301 bytes (show)
Cache misses: 1: (show)
Queries used: 9.

[Show Queries]