Color By Value Arguments in Visio 2003 VBA

I would like to add some code to color my org chart base on the value in the Status field.  I can do it manually using the Color By Values addon, but I would like to automate it.

Dim objapp As Visio.Application
Dim objaddon As Addon

    Set objapp = Visio.Application
    Set objaddon = objapp.Addons.Item("Color By Values") 'Refreshes database from Visio
    objaddon.Run ("/color = Status") '****This is the part where I need the arguments****

Any help would be appreciated.
bnielsen56Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott HelmersVisio Consultant, Trainer, Author, and DeveloperCommented:
I ann't find any documentation about this add-in that lists the commands. I've sent a query to a number of long-time Visio experts and will let you know if I hear anything useful.

Scott
0
bnielsen56Author Commented:
Thanks for checking.  I ended up adding a color loolup table to the linked database that translates the status of each position to a color, such as Vacant = 0 (visYellow) and Filled = 1 (visWhite).  Then I loop through the pages and shapes to apply the colors.  This is run when the visio document is opened, saved, or closed.
Sub ColorShapes()

Dim shpObj As Visio.Shape
Dim i As Integer
Dim clr As String
Dim docObj As Document
Dim pagsObj As Pages
Dim curPageIndx As Integer
Dim PagObj As Page
Set docObj = ThisDocument
Set pagsObj = docObj.Pages

For curPageIndx = 1 To pagsObj.Count ' iterate through the collection of pages
    Set PagObj = pagsObj.Item(curPageIndx) ' retrieve the page object at the current index
    If PagObj.Background = False Then ' Ignore if the current page is a background page
    ActiveWindow.Page = PagObj
        For i = 1 To ActivePage.Shapes.Count
            Set shpObj = ActivePage.Shapes(i)
                If shpObj.CellExists("Prop.Color", 0) Then 'Check if color cell exists in shape
                    clr = shpObj.Cells("Prop.color").ResultStr(0) 'Set color variable to color number
                    shpObj.Cells("FillForegnd").Formula = clr 'Set shape fill color to color from database
                End If
        Next
    End If
Next curPageIndx
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperCommented:
Thanks for posting the solution you developed. I've conversed with several Visio experts but so far, all I've found out is that the 'color by values' add-in is either undocumented or was documented so long ago that nobody knows where the documentation is!

If I ever track it down, I will post it here in case is helps anyone else.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Visio

From novice to tech pro — start learning today.