Author Topic: Conditional Formatting of a Shape  (Read 8054 times)

0 Members and 1 Guest are viewing this topic.

dirkasarus-rex

  • Jr. Member
  • **
  • Posts: 12
Conditional Formatting of a Shape
« on: January 28, 2015, 05:06:36 PM »
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

  • Jr. Member
  • **
  • Posts: 12
Re: Conditional Formatting of a Shape
« Reply #1 on: February 05, 2015, 10:19:56 AM »
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

  • Hero Member
  • *****
  • Posts: 3210
Re: Conditional Formatting of a Shape
« Reply #2 on: February 05, 2015, 01:45:54 PM »
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
« Last Edit: February 05, 2015, 02:58:05 PM by Yacine »
Yacine

dirkasarus-rex

  • Jr. Member
  • **
  • Posts: 12
Re: Conditional Formatting of a Shape
« Reply #3 on: February 05, 2015, 03:54:08 PM »
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

  • Hero Member
  • *****
  • Posts: 3210
Re: Conditional Formatting of a Shape
« Reply #4 on: February 06, 2015, 01:35:04 AM »
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
« Last Edit: February 23, 2015, 02:34:33 PM by Yacine »
Yacine

dirkasarus-rex

  • Jr. Member
  • **
  • Posts: 12
Re: Conditional Formatting of a Shape
« Reply #5 on: February 23, 2015, 01:20:51 PM »
[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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4840
  • Ideas Visio-lized into solutions
Re: Conditional Formatting of a Shape
« Reply #6 on: February 23, 2015, 01:51:41 PM »
Quote
I 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!

« Last Edit: February 23, 2015, 01:58:39 PM by wapperdude »
Visio 2019 Pro

Yacine

  • Hero Member
  • *****
  • Posts: 3210
Re: Conditional Formatting of a Shape
« Reply #7 on: February 23, 2015, 02:29:07 PM »
Welcome to the club!
Yacine

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4840
  • Ideas Visio-lized into solutions
Re: Conditional Formatting of a Shape
« Reply #8 on: February 23, 2015, 02:43:51 PM »
Scarred for life!

Visio 2019 Pro

dirkasarus-rex

  • Jr. Member
  • **
  • Posts: 12
Re: Conditional Formatting of a Shape
« Reply #9 on: February 27, 2015, 10:59:26 AM »
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

  • Hero Member
  • *****
  • Posts: 3210
Re: Conditional Formatting of a Shape
« Reply #10 on: February 27, 2015, 12:29:02 PM »
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