访问图表内部的形状

时间:2014-08-05 20:31:00

标签: charts parent shape

有人能指出我如何在图表内部进行塑造吗? 我在图表中制作了4个矩形,但我无法访问它们来改变他们的coulor和透明度。 lef说我有一个名为“aca”的图表,里面的形状称为“dl”....感谢表格帮助

With Worksheets("1").ChartObjects("aca")
With Parent.Shape.Range(Array("dl"))
.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0.6200000048
.Solid
End With
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 192, 0)
.Transparency = 0.6200000048
.Solid
End With
End With 

但没有运气

2 个答案:

答案 0 :(得分:0)

试试这个:

With Worksheets("1").ChartObjects("aca").Chart.Shapes.Range(Array("dl"))
    .Visible = True
End With

答案 1 :(得分:0)

我解决了这个问题:)

ddLeft = dlLeft
ddWidth = (xAxis.MaximumScale) / (xAxis.MaximumScale - xAxis.MinimumScale) * xAxis.Width + yaxis.MajorUnit * 2
ddHeight = (yaxis.MaximumScale / 2) / (yaxis.MaximumScale + yaxis.MinimumScale) * yaxis.Height
ddTop = yaxis.Top
' draw the rectangle
Set rect = cht.Rectangles.Add(ddLeft, ddTop, ddWidth, ddHeight)
With rect
.Name = "gl"
End With
With rect.ShapeRange.Fill
   .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorAccent1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0.2
        .Transparency = 0.7
        .Solid
        .ForeColor.RGB = RGB(255, 0, 0)
        End With
With rect.ShapeRange.Line
.Visible = msoFalse
End With