Visio master shape wtih ActiveX

Started by doar4forum, January 09, 2020, 01:26:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

doar4forum

 Hi,

Trying to understand if a user can create "programmable" master shapes in Visio.
Idea I am thinking:
- create a user master shape in a Macro enabled Stencil
- add to the shape a rectangle
- add to the shape an ActiveX CheckBox
    - configure the checkBox that when True to set the color of the Rectangle to RED otherwise to BLUE

The end result should be a master shape that can be added multiple times in a diagram and each of the instances to be configured by user by those ActiveX incorporated buttons.

I have tried the above (new to VBA & Visio) but cannot make  it work... is this even possible?

Thank U,
Ionut

vojo

Depending on what you want to do, don't need Activex or VBA

For example, can do color in shape shapesheet
-prop.color = <shape properties on UI>
-fillforegnd = if (prop.color = True, RGB (255,0,0), RGB (0,0,255))     // if true, then RED else BLUE

You sound like a newbie, so
File ==> adv options ==> general<go to bottom and enable developer mode>
for shape...right click ==> shapesheet <page down to fill>)

doar4forum

 Thank U for the details... I understand U can change shapes by using the ShapeSheet, but my "objective" here is to be able to integrate the ActiveX as part of the Master Shape.

If for instance I have instantiated the Master five times in a Drawing and would like different color for the Fill for each of them, it means I need to go for each one of them through this process of opening the ShapeSheet  => too many steps :D

While, if the Master has an ActiveX PullDown List, I can easily select for each Instance the Fill I want from the list => less steps and more user friendly.

I can do the above for the current drawing in VBA, but would like to be able to integrate the functionality in the Master Shape directly, rather than having to do this at Drawing Page level.

BTW: the "terminology" above might not be "Visio compatible", but hope U get the point  :)

Thank U,
Ionut

wapperdude

Shapesheet has dropdown list capability.  Can be applied to either shape data or right click action menu.
Visio 2019 Pro

vojo

no no no

you do this once and save the shape to a stencil.   Everytime you drop it on a sheet, you go to shape data and select color
Each shape is unique ...could have 3 reds and 2 blues for 5 shapes

If want "right click option"  do the shapesheet stuff and add an action row.  In that, put docmd(1312).  and save to stencil
now,everytime you drop the shape, right click it and you will see the action option (action row has some other cells of interest)
click that action option and shape data UI pops up where you can pick red or blue

see below

doar4forum

 Thank U very much for the example... very useful... I can see how it works for a shape to change the Fill color and I add it the Line color as another option... is there a way to be able to have an option to select if U want as part of that shape to show another line or not?
As in: lets say we have an rectangle and would like a User option to draw a circle in the middle. User to chose if the circle is visible or not.


vojo

Not sure what you are asking...but yes...but complicated

RE hide show action rows: 
- use the invisible cell...something like this
    - actions.parent = <something you want to show> + setf(getref(actions.parent.checked), if (actions.parent.checked =1,0,1))
    - actions.child.invisible = if (actions.parent.checked, 0,1)

RE add a circle:
- draw all shapes, the square and the circle
- group them
- do all actions at the parent
    actions.showcircle = setf(getref(action.showcircle.checked), if(actions.showcircle.checked,0,1)
- in the circle shape
     - go to geometry section
           nofill = if(actions.showcircle.checked, 0,1)
           or
           noshow = if(actions.showcircle.checked, 0 ,1)

RE groups of shape data:
- create 5 pieces of shape data for say SN, IP address, etc
- actions.show1thru3 = setf(getref(actions.show1thru3.checked), if (actions.show1thru3.checked, 0, 1) + docmd(1312)
- actions.show4thru5 = setf(getref(actions.show4thru5.checked), if (actions.show4thru5.checked, 0, 1) + docmd(1312)
- actions.reset = setf(getref(actions.show1thru3.checked), 0) + setf(getref(actions.show4thru5.checked), 0)
- shapedata visible cell for 1  ==>  invisible = if (actions.show1thru3.checked,0,1)
      - repeat for 2 and 3
      - visible cell for 4 and 5, use its check cell to show hide
Obviously gets more more complicated but can even do <show 1-3, when done, launch show 1A thru 1C, then 1AA thru 1AC>

only caution is that you should only show about 20 shape data fields per panel...otherwise, user has to manage the window size

Also, shape data at the top most group level has problems in 2013...want you to use the UI to launch not docmd(1312)
So group again...put actions in grandparent...shape data in parent....shape data in children

doar4forum

 Thank U for the details... that and the details in the below link helped to achieve what I was interested in :)
http://www.visguy.com/2007/08/16/forefront-icons-and-data-graphic-shapes/

Some follow up questions for my "learning":
- where can I find more details on possible values for the option "ButtonFace" part of the "Actions"? Is there a document that shows the "face" and number associated with it?

- U mentioned above passing actions from top to shapes contained within the group. As far as I can see from the example link above, this is done by using "=Sheet.58!User.index". Seems here that  "Sheet.58!User.index" is a user-defined cell from the top level of the group and the lower cell is accessing it by using the local sheet number. Is this what U meant with "setf(getref(actions.parent.checked)" or to use in fact the syntax "actions.parent.checked"?

Regards,
Ionut


vojo

yes
- control at top layer
- execution at bottom layer

This is good for no more than the reason of having to jump around between shapes.  If bottom layer uses a user cell from top layer, then all the calculations can be done at top layer and bottom layer references the result

One caveat, you may need to use loctopar functions to translate a given point between various frames of reference
(bottom corner right might be top middle left).