Author Topic: Shape color does not change when changing FillForegnd  (Read 905 times)

0 Members and 1 Guest are viewing this topic.

gold78

  • Newbie
  • *
  • Posts: 1
Shape color does not change when changing FillForegnd
« on: October 28, 2019, 09:31:37 AM »
Hello,

I am new to Visio and I am facing an annoying issue.

I have the following code that changes the value of FillForegnd successfully (when viewed in the ShapeSheet).

The problem is that it does not change on the screen itself.

My project is an Org Chart, where I'd like to change certain shapes' color. So in fact the shape is a group.
My loop is going through all shapes (avoiding the lines by checking the Prop.Name presence).

Code
For Each vsoshape In vsoPage.Shapes
        If vsoshape.CellExists("Prop.Name", False) Then

                 Set cell = vsoshape.Cells("FillForegnd")
                 cell.FormulaU = "RGB(255, 0, 0)"

        End If
Next

thank you and regards,


wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3828
  • Ideas Visio-lized into solutions
Re: Shape color does not change when changing FillForegnd
« Reply #1 on: October 28, 2019, 05:48:43 PM »
Syntax error, was:

Set cell = vsoshape.Cells("FillForegnd")
                 cell.FormulaU = "RGB(255, 0, 0)"

becomes:
vsoshape.Cells("FillForegnd").FormulaU = "RGB(255, 0, 0)"

Note, however, in this context, VBA sets the group color specifically, and the value does not pass down to the subshapes.  You have to additional checking for subshapes, and then change their fill.  See http://www.visguy.com/2008/05/17/detect-sub-selected-shapes-programmatically/

Visio 2019 Pro