Conditional Formatting of a Shape

Started by dirkasarus-rex, January 28, 2015, 10:06:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dirkasarus-rex

Greetings!

I have a single shape type that contains some specific metadata behind (provided by the user when they put the shape on the sheet). 

This metadata might say this [only one value provided for each category]:
Product: Fruit/Vegetable/Dairy
Color: Red/Yellow/Blue
Action: Buy/Sell/Trade

What I'd like to have happen is for the user to use as many of this specific shape as necessary in the drawing, then, at the top of the drawing have a control that says something like: Category: Product/Color/Action -- and provide content -- Value: ...

So the user then sets it this way: Category: Action  Value: Buy

I want all the shapes on the sheet that have metadata combination of Action:Buy to turn a different color.  The user could then change the values to say Product:Fruit and those would change to the color, the first ones back to white.

Any idea of how I'd approach this?

Thank you in advance!

Dirkasarus-Rex

dirkasarus-rex

I wanted to provide a followup on how I'm going to solve this puzzle for the possible benefit of others.

First, I will put a set of custom data fields in the shape(s) that are to be affected by this behavior.  The prompt section will provide the possible values for each data point (If someone knows how to put a dropdown list in these data fields, that would be ideal.)

I am putting VBA code into the stencil that will automatically place a button on the ribbon to gain access to the "Colorizer."   When a user clicks this button, they will have a custom user form show up.  During the process of loading the Colorizer, the code will scan all shapes on the page creating a unique list of the data labels and values.  This way if a user adds another custom data field or misspells the values, it will appear as such in the Colorizer.  The form will then display a list of the available fields and when the user clicks on a field, a second list to the right will display all possible values.  The user then clicks on a value from the second list and selects the OK button.

The code then takes the user's selections, and scans the shapes once more looking for this combination and when a match is found, the shape has its foreground color changed to the desired value.

In the Colorizer there will also be a checkbox to 'reset' the shapes.  When selected, the two list boxes will be disabled, clicking OK will reset the color of all the shapes back to white.

I welcome comments to this approach.  :o

With warm regards,

Dirkasarus-rex

Yacine

#2
Hi Dirk,
I don't think  a macro is necessary for this task.
Just plain ol shapesheet techniques can do the trick.
It's a little bit late for trying to formulate a proper explanation, but here the most important points:
- use the shape data of the page to set the configuration to highlight
- let your master shape watch the shape data of the page to decide on how to set its highlight or normal display


And by the way, to set up a dropdown list, set the row type in the custom properties to 1, then populate the format field with a semi-colon separated list.
You'll see that in both the page's shapesheet, as the master's one.


Regards,
Yacine
Yacine

dirkasarus-rex

Yacine,

I downloaded your example and as a Visio Customizing Newbie, have more questions than I know to ask.  I do agree, staying away from VBA would be the preferred option as there are certainly issues with getting users to turn on the macros in their individual Visio instances.

1. How do you suggest to use the page's shape sheet to set the config to highlight?
2. How do you suggest to configure the master shape to watch the page's shape sheet?
3. How do you suggest that a user would be able to set the criteria and affect the change of the drawing?

Using the VBA technique, the training for the users would be to click on the new button in the ribbon, a reasonably intuitive user entry form will be presented and when they click OK it does it's magic.

To set the shape data correctly will be the responsibility of the sheet designer.  This is a very small group of people so training is minimal.

I very much appreciate your insight on this little project.  Thank you!

Dirkasarus-Rex

Yacine

#4
1. Having no shapes selected and the custom properties window displayed, you'll see properties. They belong to the page. There you can set the combination, you want to highlight.
2. The shapes are already configured. Modify some of them to display the same combo as the page. They should highlight.
3. Modifying shape is a basic task in visio, that users can be expected to understand. You can however still put a macro over this construct to have an input mask, but that's just an esthetic issue. The behaviour is already set in the shapes and the page.
4. Of course the right shapes would be designed by yourself and stored in the stencil. The users will need to use only them
Yacine

dirkasarus-rex

[Follow-up]

To solve this puzzle, I built the code behind a stencil.  The shapes of the stencil have data elements defined.  I have code that puts the macro code into a ribbon element so that is available to the user.  The user is free to drop the shapes on to a drawing, then put the necessary values into the data elements behind the shapes.

When the user clicks on the ribbon element, the colorizer code is run.  It iterates across all shapes (and shapes contained within a group) and catalogs all the data labels and associated values, creating a unique list.  It then displays a user form where the user can choose a data label and value combination (two list boxes) along with a color to fill the shapes.  Further, there is a 'reset' check box allowing the coloring to be reverted to white if desired.  When the user clicks "OK" in the user form, the macro iterates through the shapes again, this time filling the shapes that match the criteria with the chosen color.

I wanted to thank Yacine for her feedback on various technical elements of this project.  The stencil is now in production within my company.   8)

wapperdude

#6
QuoteI wanted to thank Yacine for her feedback on various technical elements of this project.

Ah!  A new member to the Yacine Mis-gender club!  Welcome!   ::)   ;D  It is a club with significant membership numbers!   ???

Yacine, of course, is "he", not "she".  LOL

Wapperdude

PS.:  Reminds me of Johnny Cash's hit song, "A Boy Named Sue".  Except Yacine doesn't seem nearly as mean!

Visio 2019 Pro

Yacine

Yacine

wapperdude

Visio 2019 Pro

dirkasarus-rex

Seriously, dude, that's what they make 'visio' straps for, to keep that junk from dangling like that.

Ouch!  That really hurt the eyes.

Yacine

A "YacineDude" would help, but why should I try to prevent all that fun? This forum is already too serious!
I'm fine with jokes about myself.
Yacine