有谁知道如何获取 Excel ChartObjects Count?在 VBA 示例中,我可以在一张表中获取所有图表名称和图表计数。但我不知道为什么,python 无法获取图表计数。我尝试了所有其他 ChartObjects 属性,除了 Count 之外的所有工作。
[MSDN Library][1]
ChartObjects.Application Property (Excel)
Not Working ===> ChartObjects.Count Property (Excel)
ChartObjects.Creator Property (Excel)
ChartObjects.Height Property (Excel)
ChartObjects.Left Property (Excel)
ChartObjects.Locked Property (Excel)
ChartObjects.Parent Property (Excel)
ChartObjects.Placement Property (Excel)
ChartObjects.PrintObject Property (Excel)
ChartObjects.ProtectChartObject Property (Excel)
ChartObjects.ShapeRange Property (Excel)
ChartObjects.Top Property (Excel)
ChartObjects.Visible Property (Excel)
ChartObjects.Width Property (Excel)
ex.
Python:
workbook.Sheets(2).ChartObjects.Count
VBA:
ActiveWorkbook.Sheets(lngS).ChartObjects.Count
来自 Python 的错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "F:\Python27\lib\site-packages\win32com\client\__init__.py", line 465, in
__getattr__
raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr
))
AttributeError: '<win32com.gen_py.Microsoft Excel 14.0 Object Library.ChartObjec
t instance at 0x51078984>' object has no attribute 'Count'
[1]: http://msdn.microsoft.com/en-us/library/ff846604%28v=office.14%29.aspx