Link to home
Create AccountLog in
Avatar of bamoon
bamoonFlag for Afghanistan

asked on

Color By Values Automation

I am trying to automate an add on process for an org chart.  The process in Visio is Tools> Addons> Building Plan > Color By Values.  I am using a hidden custom property as the conditional value.  I am using Visio 2003.  I am trying to find the command line to use for this in VBA i.e. vsoApp.Addons.ItemU("??").Run("/???some argument").  I have spend hours looking for this but have not been able to find anything on it.  Thanks.
Avatar of Scott Helmers
Scott Helmers
Flag of United States of America image

I found some very old code that I think will do the trick. I can't test it at the moment because it requires Visio 2003 or earlier and I don't have a machine available tonight with that version. However, I can get to one tomorrow if you have any problem with this. Note the two commented out lines that I think will provide help on other commands that might exist.
Sub RunCBVAddin()

    Dim oApp As Application
    Dim oAddon As Addon

    Set oApp = Visio.Application
    Set oAddon = oApp.Addons.Item("Color By Values")

    'oAddon.Run ("/?")
    'oAddon.Run ("/HELP")    
    oAddon.Run ("/COLORBY=Title")

Open in new window

End Sub
Avatar of bamoon


Is there anyway to add the parameters without the Color By Value popping up for each page? It does not seem to be accepting the parameters i.e. /COLORBY=Region.
I've fired up a VM with Visio 2003 and you're right -- the CBV add-in totally ignores paratemers. Apparently all the code succeeds in doing is to run the add-in so it can open its dialog.

Please keep in mind that support for the CBV add-in was dropped in Visio 2007, which means that Microsoft stopped working on it 5-7 years ago.

Microsoft dropped support for the CBV add-in because they built a vastly better replacement in Visio 2007 PRO and later -- the data graphics feature includes multiple options, one of which is color by value (scroll toward the bottom of the linked page).

Consequently, if you have to stay with Visio 2003 PRO you're stuck with what you have. If you can upgrade to Visio 2010 or 2013, you'll find *a lot* to like, including a much more flexible color by value feature.
Avatar of bamoon


Ok thanks is there a way then in 2003 that I can color the shapes in the org chart based on the value in a custom property?
Avatar of bamoon


Got it thanks, here it is if anybody needs it

Note you may need to change the value 2 based on where your custom property is

'Set the color of the shape based on the custom property Region
                sRegion = vsoShp.CellsSRC(Visio.VisSectionIndices.visSectionProp, 2, Visio.VisCellIndices.visCustPropsValue).FormulaU
                If sRegion = Chr(34) & "Merrimack Region" & Chr(34) Then
                    vsoShp.CellsSRC(visSectionObject, visRowFill, visFillForegnd).Formula = "RGB(0,255,0)"
                End If
Avatar of Scott Helmers
Scott Helmers
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
BTW, feel free to award yourself most of the points since you did find an answer to your own question. And thanks for posting it for others to see.