With MsChart1.Plot Dim objPen As Pen Set objPen = .SeriesCollection(1).Pen'获得系列1的画笔对象 objPen.VtColor.Set 100, 100, 100'设定其颜色 Set objPen = .SeriesCollection(2).Pen'获得系列2的画笔对象 objPen.VtColor.Set 255, 10, 100'设定其颜色 '等等…… '设定X坐标轴字体,大小及颜色 .Axis(VtChAxisIdX).AxisTitle.VtFont.Name = "黑体" .Axis(VtChAxisIdX).AxisTitle.VtFont.Size = 24 .Axis(VtChAxisIdX).AxisTitle.VtFont.VtColor.Red = 255 '等等…… End With 还有其他一些背景、后墙,网格颜色设置方法都差不多
可以在代码中改变的,不过要添加一个颜色对话框 With MSChart.Plot.SeriesCollection(index).DataPoints(-1) .Brush.Style = VtBrushStyleSolid .Brush.FillColor.Set red, green, blue End With 上述代码中的index为具体每一列,因为颜色对话框中显示的颜色值不是RGB格式的,所以要转化一下,red,green,blue用下面的函数把对话框的颜色属性转化为RGB格式的 Public Function RedFromRGB(ByVal rgb As Long) _ As Integer RedFromRGB = &HFF& And rgb End FunctionPublic Function GreenFromRGB(ByVal rgb As Long) _ As Integer GreenFromRGB = (&HFF00& And rgb) \ 256 End FunctionPublic Function BlueFromRGB(ByVal rgb As Long) _ As Integer BlueFromRGB = (&HFF0000 And rgb) \ 65536 End Function
Dim objPen As Pen
Set objPen = .SeriesCollection(1).Pen'获得系列1的画笔对象
objPen.VtColor.Set 100, 100, 100'设定其颜色 Set objPen = .SeriesCollection(2).Pen'获得系列2的画笔对象
objPen.VtColor.Set 255, 10, 100'设定其颜色 '等等…… '设定X坐标轴字体,大小及颜色
.Axis(VtChAxisIdX).AxisTitle.VtFont.Name = "黑体"
.Axis(VtChAxisIdX).AxisTitle.VtFont.Size = 24
.Axis(VtChAxisIdX).AxisTitle.VtFont.VtColor.Red = 255 '等等……
End With
还有其他一些背景、后墙,网格颜色设置方法都差不多
With MSChart.Plot.SeriesCollection(index).DataPoints(-1)
.Brush.Style = VtBrushStyleSolid
.Brush.FillColor.Set red, green, blue
End With
上述代码中的index为具体每一列,因为颜色对话框中显示的颜色值不是RGB格式的,所以要转化一下,red,green,blue用下面的函数把对话框的颜色属性转化为RGB格式的
Public Function RedFromRGB(ByVal rgb As Long) _
As Integer
RedFromRGB = &HFF& And rgb
End FunctionPublic Function GreenFromRGB(ByVal rgb As Long) _
As Integer
GreenFromRGB = (&HFF00& And rgb) \ 256
End FunctionPublic Function BlueFromRGB(ByVal rgb As Long) _
As Integer
BlueFromRGB = (&HFF0000 And rgb) \ 65536
End Function