J
joegarber
So I have no problem changing the layer color, as shown by the line in
the code below with the comment "This line works...". But what I want
to do is change the foreground color of all the shapes in the layer.
It's supposed to change the color of all the shapes in the layer that
has the same name as the referenced shape's text. When changing the
layer color, it does that correctly; but when I try to change the
foreground color of each shape in the layer, it changes the color of
EVERY shape on the entire page.
I'm brand new to Visio and VBA... lil' help?
Public Sub ToggleLayerColor(ByRef shp As Visio.Shape)
Dim pagObj As Visio.Page
Dim layersObj As Visio.Layers
Dim layerObj As Visio.Layer
Dim shpsObj As Visio.Shapes
Dim shpObj As Visio.Shape
Dim i1 As Integer
Dim sLayer As String
sLayer = shp.Text
Set pagObj = ActiveDocument.Pages(1)
Set layersObj = pagObj.Layers
For Each layerObj In layersObj
If UCase(layerObj.Name) = UCase(sLayer) Then
'layerObj.CellsC(visLayerColor).FormulaU = "2" This line works
'Exit For
Set shpsObj = layerObj.Page.Shapes
For Each shpObj In shpsObj
shpObj.Cells("FillForegnd") = "2" ' Here is problem
Next
Exit For
End If
Next
End Sub
the code below with the comment "This line works...". But what I want
to do is change the foreground color of all the shapes in the layer.
It's supposed to change the color of all the shapes in the layer that
has the same name as the referenced shape's text. When changing the
layer color, it does that correctly; but when I try to change the
foreground color of each shape in the layer, it changes the color of
EVERY shape on the entire page.
I'm brand new to Visio and VBA... lil' help?
Public Sub ToggleLayerColor(ByRef shp As Visio.Shape)
Dim pagObj As Visio.Page
Dim layersObj As Visio.Layers
Dim layerObj As Visio.Layer
Dim shpsObj As Visio.Shapes
Dim shpObj As Visio.Shape
Dim i1 As Integer
Dim sLayer As String
sLayer = shp.Text
Set pagObj = ActiveDocument.Pages(1)
Set layersObj = pagObj.Layers
For Each layerObj In layersObj
If UCase(layerObj.Name) = UCase(sLayer) Then
'layerObj.CellsC(visLayerColor).FormulaU = "2" This line works
'Exit For
Set shpsObj = layerObj.Page.Shapes
For Each shpObj In shpsObj
shpObj.Cells("FillForegnd") = "2" ' Here is problem
Next
Exit For
End If
Next
End Sub