Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: gold78 on October 28, 2019, 02:31:37 PM

Title: Shape color does not change when changing FillForegnd
Post by: gold78 on October 28, 2019, 02:31:37 PM
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).


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,

Title: Re: Shape color does not change when changing FillForegnd
Post by: wapperdude on October 28, 2019, 10: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/ (http://www.visguy.com/2008/05/17/detect-sub-selected-shapes-programmatically/)