AttributeError: '<win32com.gen_py.Microsoft Excel 14.0 ObjectLibrary.Shape instance at 0x70837752>'

J

Jaydeep Patil

I have created chart object. But unable to add series into chart.
Look at below collection

Code:

chartObj = addNewChart(newws,-4169,350,600)
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
chartObj.SeriesCollection().NewSeries()
File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 465, in __getattr__
raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr))



Regards
Jaydeep Patil
 
J

Jaydeep Patil

Your code isn't self-contained (we are not able to run it as you

presented it).



Are you relying on some specific third-party library? If so, you need to

be explicit. You may also get better response if you ask for help on the

specific discussion forums for that library.



--

\ "My classmates would copulate with anything that moved, but I |

`\ never saw any reason to limit myself." --Emo Philips |

_o__) |

Ben Finney

Hi...
Just consider that you have chart object & you need to add data series for that chart. How you can add this?

Let me know.

I try to add data series using below command. But it gives error.

Command:
chartObj.SeriesCollection().NewSeries()


Error:
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
chartObj.SeriesCollection().NewSeries()
File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 465, in __getattr__
raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr))


Regards
Jay
 
T

Tim Golden

Just consider that you have chart object & you need to add data series for that chart. How you can add this?

Jaydeep: you're writing to a general Python list. Few of the people here
run on Windows; fewer still will use Python to automate Excel via COM; a
tiny number (possibly zero) will have experience of generating Charts in
Excel.


It's not that people are unwilling to help, but you have to meet us
halfway: write a few lines of code which take us to the point you're at
that we can run with *just* Python and the pywin32 libraries. Don't call
a function you've defined somewhere else because we can't see the function.

Something like this:

import win32com.client

xl = win32com.client.gencache.EnsureDispatch("Excel.Application")
wb = xl.Workbooks.Add()

#
# Something here to create a chart so we can help you out
#


TJG
 
S

Stefan Schukat

Hello,

the "chartObj" is not a Chart object it is a shape see <win32com.gen_py.Microsoft Excel 14.0 Object Library.Shape ...
Hence this object has no SeriesCollection try the Chart Attribute of the shape object.
from win32com.client import Dispatch
Excel = Dispatch("Excel.Application")
WB = Excel.Workbooks.Add()
Shape = WB.Sheets[0].Shapes.AddChart()
Shape.Chart.SeriesCollection
<bound method CDispatch.SeriesCollection of <COMObject <unknown>>>


Regards

Stefan Schukat


-----Original Message-----
From: Python-list [mailto:p[email protected]] On Behalf Of Jaydeep Patil
Sent: Thursday, February 13, 2014 12:05 PM
To: (e-mail address removed)
Subject: AttributeError: '<win32com.gen_py.Microsoft Excel 14.0 Object Library.Shape instance at 0x70837752>' object has no attribute 'SeriesCollection'

I have created chart object. But unable to add series into chart.
Look at below collection

Code:

chartObj = addNewChart(newws,-4169,350,600)
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
chartObj.SeriesCollection().NewSeries()
File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 465, in __getattr__
raise AttributeError("'%s' object has no attribute '%s'" % (repr(self),attr))



Regards
Jaydeep Patil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top