With Python win32com how to get a reference to a chart data table?
I can create a chart with a data table (PowerPoint pops it up in a separate window) like:
import win32com
from MSO import constants as msoconst
Application = win32com.client.Dispatch("PowerPoint.Application")
Application.Visible = True
Presentation = Application.Presentations.Add()
FirstSlide = Presentation.Slides.Add(1, 12)
... no problem adding slides, shapes and text and setting font size and color ....
InventoryChart = FirstSlide.Shapes.AddChart2(201,msoconst.xlColumnClustered ,10,80,470,220,False) # 0 = Clustered Column, 1 = Combo Area, 2 = Clustered Column
InventoryChartData = InventoryChart.ChartData
ChartData doesn't work: AttributeError: '' object has no attribute 'ChartData'
So, how do you get a reference to the table that PowerPoint creates? Or how do I define the table to be used for my data?
I had the same question a while back and spent a lot of time trying to find an answer.
ChartData is a property of the Chart object. So to access the ChartData object, you need to tell PowerPoint that the shape you just added is a Chart.
Here are two ways to do do that.