Vba Excel图形图例不';不匹配标记

Vba Excel图形图例不';不匹配标记,vba,excel,excel-2010,Vba,Excel,Excel 2010,我已使用VBA格式化图表的标记: Dim sc As SeriesCollection Set sc = MySheet.ChartObjects("MyChart").Chart.SeriesCollection Dim p As Point, s As Series For Each s In sc For Each p In s.Points p.Format.Fill.ForeColor.RGB = s.Format.Line.ForeCol

我已使用VBA格式化图表的标记:

Dim sc As SeriesCollection
Set sc = MySheet.ChartObjects("MyChart").Chart.SeriesCollection

Dim p As Point, s As Series
For Each s In sc
    For Each p In s.Points
        p.Format.Fill.ForeColor.RGB = s.Format.Line.ForeColor.RGB
        p.Format.Fill.BackColor.RGB = s.Format.Line.ForeColor.RGB
        p.MarkerSize = 3
    Next p
Next s
但是,图表区域中的标记与图例中的标记不匹配(边框颜色相同,但图例中的填充颜色不同)。注意右侧方框内的颜色(图例):


我已经查看了Chart系列的一些不同属性,但找不到是什么控制了这一点。
properties
MarkerBackgroundColor
markerforeggroundcolor
似乎很可能出现,但不要修复它。如何修复此问题?

通过进一步挖掘发现:

Worksheet.ChartObjects(Index).Chart.Item(Index).Format.Fill.ForeColor.RGB

相当长

由于您正在循环seriescollection,您只需一次完成所有标记:

For Each s In sc
    s.MarkerBackgroundColor = s.Border.Color
    s.MarkerSize = 3
Next s

以这种方式重新格式化整个序列时,图例符号也会选择格式。逐点重新格式化时,即使重新格式化序列中的每个点,序列本身(和图例)也会保留原始格式。Rory在下面的回答显示了一次格式化整个系列的方法。点格式特性也可用于该系列。