|
所有的代码如下:其功能就是让柱形图标的每根柱子能够变颜色
Dim cht As Chart
Dim chtData As ChartData
Dim wb As Object
Dim ws As Object
Dim shp As Shape
Sub creatchart()
Set shp = ActivePresentation.Slides(1).Shapes.AddChart(xlBarClustered, 20, 50, 600, 400)
If shp.Type = msoChart Then
Set cht = shp.Chart
End If
If cht Is Nothing Then Exit Sub
Set wb = cht.ChartData.Workbook
Set ws = wb.worksheets(1)
ws.listobjects(1).resize ws.Range("A1:B5")
ws.Range("B1").Value = "sldjlkad"
ws.Range("A2:B2").Value = Array("American", 14.8)
ws.Range("A3:B3").Value = Array("China", 5.3)
ws.Range("A4:B4").Value = Array("Japan", 5)
ws.Range("A5:B5").Value = Array("German", 3.5)
cht.ApplyDataLabels xlDataLabelsShowValue
'ActivePresentation.Slides(1).ChartObjects("aa").SeriesCollection(1).Points(1).Interior.ColorIndex = 3
cht.SeriesCollection(1).Points(1).Interior.ColorIndex = 5
' wb.Application.Quit
End Sub
Sub ss()
' Dim shp1 As Shape
' Dim cht1 As Chart
' Dim wb As Object
Set shp = ActivePresentation.Slides(1).Shapes(1)
Set cht = shp.Chart
cht.SeriesCollection(1).Points(3).Interior.ColorIndex = 1 问题出在这个语句上,无论这个值怎么改变,柱形都是红色的。3才是红色,可换成1照样也还是红色。
End Sub
求高手帮忙解决
|
|