Author Topic: 'Conditional Formatting' for Visio Org-Charts?  (Read 21429 times)

0 Members and 1 Guest are viewing this topic.

oli

  • Newbie
  • *
  • Posts: 2
'Conditional Formatting' for Visio Org-Charts?
« on: November 17, 2010, 05:17:37 AM »
Hi all,

Please appreciate that even though I would call myself proficient in other Office programmes, Visio is something that I haven't had the chance to use (until now)!.

At the moment I have a large excel file with the first 4 columns containing:
  • Employee reference number
  • Employee Name
  • Reference number of employee they report to
  • Role

So far I've been able to make an org chart using the Wizard however the next step is to make it so that each shape changes colour automatically depending on the employee's role.

Can anyone point me in the right direction so I can try to learn how to do this?

Thanks in advance,
Oli

aledlund

  • Hero Member
  • *****
  • Posts: 1412
Re: 'Conditional Formatting' for Visio Org-Charts?
« Reply #1 on: November 17, 2010, 07:30:07 AM »
If you're at visio 2003 or lower you can use the color by value add-in. If you're at v2007 (pro) or above you can use datagraphics and the color by value.
al

oli

  • Newbie
  • *
  • Posts: 2
Re: 'Conditional Formatting' for Visio Org-Charts?
« Reply #2 on: November 18, 2010, 04:48:33 AM »
Many thanks aledlund,

Just checking that for Visio 07 this automatic formatting is only available on Visio Professional?

Cheers,
Oli

aledlund

  • Hero Member
  • *****
  • Posts: 1412
Re: 'Conditional Formatting' for Visio Org-Charts?
« Reply #3 on: November 18, 2010, 07:37:09 AM »
The color-by-value addin is in v2007 (and I believe is in the standard version as well). On my system I get to it by Tools => add-ons => maps and floorplans. You might check this out

http://office.microsoft.com/en-us/visio-help/color-code-your-visio-network-diagrams-HA001077999.aspx

al

karininwinnipeg

  • Jr. Member
  • **
  • Posts: 18
Re: 'Conditional Formatting' for Visio Org-Charts?
« Reply #4 on: January 07, 2015, 08:05:52 PM »
I just looked for this in Visio 2013. I found it, under the View tab (View>Add-Ons>Maps and Floor Plans), but when you choose it, you just get a message informing you that this add-on has been replaced by the data graphics feature. I have to check if it's available in 2010.

Does anyone know of a way to automatically color a shape based on a piece of custom data that will work in versions 2010 and/or 2013?

Thanks.
« Last Edit: January 07, 2015, 08:13:50 PM by karininwinnipeg »

Yacine

  • Hero Member
  • *****
  • Posts: 2747
Re: 'Conditional Formatting' for Visio Org-Charts?
« Reply #5 on: January 08, 2015, 12:30:03 PM »
Hi Karin,
you could write your own little vba routine.
Yacine

karininwinnipeg

  • Jr. Member
  • **
  • Posts: 18
Re: 'Conditional Formatting' for Visio Org-Charts?
« Reply #6 on: January 17, 2015, 02:17:25 AM »
Quote
you could write your own little vba routine.

Hmm. Not sure my students would be as excited about that as I am, but hey, I'll give it a go. If you can point me to a working example, or an article etc., that would be very helpful.

Thanks!

Karin

Yacine

  • Hero Member
  • *****
  • Posts: 2747
Re: 'Conditional Formatting' for Visio Org-Charts?
« Reply #7 on: January 17, 2015, 05:17:02 AM »
After having started to write "the" small routine for you, I realized how endless the possibilities are ...
and considering that you are not looking for a solution for yourself, but teaching visio, I prefered to share my thoughts about this problem with you instead.

The very simplest way to solve the problem is to write a hard coded routine.
Something like:

Code
for each shp in activepage.shapes
if shp.cellexists("prop.RowXY", false) then
  select case shp.cells("prop.RowXY").Resultstr("")
  case "Value1": temp = "RGB(10,10,10)"
  case "Value2": temp = "RGB(255,10,10)"
  end select
  shp.CellsSRC(visSectionObject, visRowFill, visFillForegnd).FormulaU=temp
end if
next shp


This routine will color the shapes as requested, but it lacks any flexibility.
If the field to consider, or the colors chosen change, then one has to modify the code.
It definitely lacks comfort.


So here comes what Visio is all about, graphics with data and the comprehension, that the solutions (addons) provided are not immutable. Everyone can do everything with Visio. It's just about the willingness to invest a certain effort to automate things.

Speaking about your problem, I could imagine wanting to have a dialog in which I could chose the field to consider.
The user could type in manually the name for the "prop" field, ... or even better chose it from a list of available fields.
To get the list of fields, the code would need to iterate through all the shapes of the page, then through all the rows of the custom properties section (or more) and add this field to a COLLECTION, then populate a list with the values of the collection. (I did highlight the term collection, because it is an object available in VBA that provides the easiest way to build a "list" of distinct values).


Same for the color values to assign.
There could by distinct values - with property values corresponding to defined colors,
or there could be continuous values translated in values of RGB.


To get the possible values of a certain field, the code would also need to iterate through all the shapes and add every distinct one to a collection.


Next would be a possibility to store such "coloring" shemes and you're in exporting and importing excel data or other more elaborate types of database formats.


I do of course not know your audience, and how ready they are to dive into Visio, but that would be a definite plus to every Visio course.


Cheers,
Yacine
« Last Edit: January 17, 2015, 05:56:08 AM by Yacine »
Yacine

karininwinnipeg

  • Jr. Member
  • **
  • Posts: 18
Re: 'Conditional Formatting' for Visio Org-Charts?
« Reply #8 on: January 17, 2015, 07:57:31 PM »
Thank you for that detailed response! I think I may incorporate this into a demo, but the general skill level and background of the particular class I'm prepping for is probably not advanced enough to start discussing VBA and variables etc. If it were a 2-day course it would fit nicely. I found another solution that I am experimenting with right now where you write an IF statement in the chosen property (in the ShapeSheet). When I have a solution I might just post it for others to see and use.  :D

Have a great day!

Karin

Nabil

  • Newbie
  • *
  • Posts: 1
Re: 'Conditional Formatting' for Visio Org-Charts?
« Reply #9 on: May 11, 2015, 01:46:06 AM »
Thank you  :)