Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Jacksonville, North Carolina, USA
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Org Charts (11.8161.8172)

    I have generated an org chart utilizing information from an Access database. However, on the org chart I need the fill color of the shapes to be color coded based on the city in which the employee lives. So that at a visual glance I can see where employees live. How can I tell Visio that if employee lives in XYZ then fill color on org chart should be red; if employee lives in ABC fill color on org chart will be blue; etc.?

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Org Charts (11.8161.8172)

    You can probably do this more elegantly but here is one solution.

    I'll assume that you have imported the location field into the Custom Property called 'Department'. It doesn't have to be but you haven't told us where this information might be stored so I'll just make this assumption.

    Now create styles for each of your colour codings. In this example, I'll assume you have created styles called 'East', 'West', 'Other'

    Now place this code in a VBA module and run it on your org chart

    Sub ColourMe()
    Dim aShp as Visio.Shape
    For Each aShp in ActivePage.Shapes
    If aShp.CellExists("Prop.Department", True) Then
    Select Case aShp.Cells("Prop.Department").FormulaU
    Case """East"""
    aShp.FillStyle = "East"
    Case """West"""
    aShp.FillStyle = "West"
    Case Else
    aShp.FillStyle = "Other"
    End If
    Next aShp
    End Sub

    A different solution might be to alter the master shapes properties (via the shape sheet) to change the FillFormat.FillForeground. This one would have the advantage of not needing VBA but will also take more planning for a solid implementation.

    For instance, you could modify the the value of the FillForeground to =If(Prop.Department="East",RGB(50,50,50),RGB(200,5 0,50))
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Jacksonville, North Carolina, USA
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Org Charts (11.8161.8172)

    I copied your codes and updated Department to City and cases appropriately to match my styles that I created. When I try to run the code I get "Compile Error: End If without block If" message. Any suggestions?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Org Charts (11.8161.8172)

    Andrew forgot an End Select:
    <code>
    Sub ColourMe()
    Dim aShp As Visio.Shape
    For Each aShp In ActivePage.Shapes
    If aShp.CellExists("Prop.Department", True) Then
    Select Case aShp.Cells("Prop.Department").FormulaU
    Case """East"""
    aShp.FillStyle = "East"
    Case """West"""
    aShp.FillStyle = "West"
    Case Else
    aShp.FillStyle = "Other"
    End Select
    End If
    Next aShp
    End Sub
    </code>
    (I don't have Visio, so I cannot test the code)

  5. #5
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Org Charts (11.8161.8172)

    Thanks for fixing the mistyped code Hans - I was transcribing it from another PC and missed one.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •