用颜色填充图形

Ark*_*usz 0 vba

我想在我的图表上格式化系列,我注册了宏:

ActiveChart.FullSeriesCollection(1).Select
With Selection.Format.Fill
    .Visible = msoTrue
    .ForeColor.RGB = RGB(146, 208, 80)
    .Transparency = 0
    .Solid
End With
Run Code Online (Sandbox Code Playgroud)

然后我把它放到我的代码中:

        With Wykres
            .ShowLegendFieldButtons = False
            .ShowValueFieldButtons = False
            .ShowAxisFieldButtons = False
            .ShowAllFieldButtons = False
            .Legend.Delete
            .ChartStyle = 340
            .SetElement (msoElementChartTitleAboveChart)
            .ChartTitle.Text = "Ilo?? w podziale na województwa"
            .SetElement (msoElementDataLabelOutSideEnd)
            .Parent.RoundedCorners = True
            .ChartArea.Format.Line.ForeColor.RGB = KolorUzytkownika
            .FullSeriesCollection.Format.Fill.ForeColor.RGB = KolorUzytkownika
        End With
Run Code Online (Sandbox Code Playgroud)

但是我的代码的最后一行出了点问题.我收到消息:"对象不支持此属性或方法".我使用后期绑定,但我想这并不重要.

cyb*_*shu 6

.FullSeriesCollection是类型的Collection.您不能访问/修改类型的属性SeriesCollection类型.因此错误.

在此输入图像描述

您需要首先从集合中访问该项目,然后才能访问该项目类型的所有公共属性和方法.

.FullSeriesCollection(1).Format.Fill.ForeColor.RGB = RGB(255, 0, 0)