Reputation: 1456
I would like to select the objects by the color.
So far I did something like this:
If Vshp.CellsU("FillForegnd").FormulaU = "RGB(128,128,128)" Then
sel.Select Vshp, visSelect
End If
But I see no reaction at all.
I picked it from here:
Visio change color of all child elements using VBA
and here:
VBA Change the Color of a Rounded Rectangle in Visio
Is there any way of how I could pick up the shapes by their exact RGB colour?
UPDATE:
With the following approach:
If Vshp.Shapes(4).CellsU("FillForegnd").FormulaU = "RGB(128,128,128)"
Then
sel.Select Vshp, visSelect
End If
I receive the following error:
Invalid Sheet identifier
Pointing out the line: If Vshp.Shapes(4).CellsU("FillForegnd").FormulaU = "RGB(128,128,128)"
The following threads: "Shape.ConnectedShapes method (Visio)" example from Microsoft site give "Invalid Sheet Identifier" error http://visguy.com/vgforum/index.php?topic=9713.0 Weren't helpful for me
UPDATE II:
I realized, that the subshape cannot be .Shape(4)
, because it's the text.
I just need to know how to read the Drawing explorer window, because I see multiple of the same shapes in my layer and I have no clue which one should correspond to the Cabinet(Fibre Schematic).2125
, or alternatively could I pick them up by name?.
UPDATE III
After searching the solution I found a nice hint here:
http://visguy.com/vgforum/index.php?topic=7577.0
but unfortunately it doesn't work with the manner I would like to apply:
The current code:
For Each subshp In vShp.Shapes
If subshp.CellsU("FillForeground").FormulaU = "RGB(128,128,128)" Then
ActiveWindow.Select subshp, visSubSelect
End If
Next subshp
Throws the error:
Unexpected end of file
At the line:
If subshp.CellsU("FillForeground").FormulaU = "RGB(128,128,128)" Then
Upvotes: 0
Views: 536
Reputation: 1734
I need to select a few whole shapes (including sub-shapes) in one line, but I guess, selection all sub-shapes by their colour can be good
IMHO selection of sub-shapes in not good idea!
Hope these gif-animations can explain difference.
Even in we select all shape with some color. How we can align them ALL?
you can explore the contents of the group using the Drawing Explorer window
If subshp.CellsU("FillForeground").FormulaU = "RGB(128,128,128)" Then
Por this purpose better use ResultStr property. With syntax like
If subshp.CellsU("FillForeground").Resultstr(visNone) = "RGB(128,128,128)"
This picture show difference of representation Formulas in ShapeSheet (FormulaU in VBA) and Values (ResultStr).
Themes in MS Visio are most ugliest feature.
If you apply som Theme and Shapes changed their fill colors, but in ShapeSheet in this cell you can see constant in Values or Formulas representation!!!
Upvotes: 1
Reputation: 1456
Indeed, unlike the previous answer, you would be able to select the whole shape by its sub-shape.
Basing on this thread: http://visguy.com/vgforum/index.php?topic=7577.0
We are able to select any subshape falling inside the shape, but also the shape by the subshape properties.
For Each vShp In VPage.Shapes
For Each subShp In vShp.Shapes
If subShp.CellsU("FillForegnd").FormulaU = "THEMEGUARD(RGB(191,127,255))" Then
ActiveWindow.Select vShp, visSubSelect
End If
Next subShp
Next vShp
It's important to pick up the color straight from the formula presented in the ShapeSheet design
Once used in he manner as above, we are able to select just the particular part of our drawing, which shapes include the subshapes with this colour.
Upvotes: 0