On 25/08/2011 17:50, Tom wrote:
Hello all,
I am writing a reporting application that uses word's COM interface. I
recently found myself needing to insert a chart into the document, and
the "AddChart" method seemed ideal
(http://msdn.microsoft.com/en-us/library/bb226069(v=office.12).aspx).
The code is this:
image_chart =
word.ActiveWindow.Selection.InlineShapes.AddChart(Type=constants.xlBarClustered)
chart = image_chart.Chart
chart.ChartData.Activate()
... fill chart with data ...

This runs fine on my laptop machine (Windows 7) and a little excel
window pops up with some basic starting data that my application
modifies. I deployed it to our Windows 2003 server and I was dismayed to
find that it failed. The issue was that image_chart had no Chart
attribute, no exception is being raised when AddChart is called and an
object is returned as normal, just without a Chart (and thus no ability
to edit the data?). I did a little digging around and it seems that
excel is spawned when I call AddChart, but it quits a second or two
afterwards for no apparent reason, according to the event viewer "Excel
terminated normally after a runtime of 1 seconds".

The code is being called from a Celery task queue (so it is called from
within a thread), and this has not been an issue before - the code is
incredibly COM heavy. However when I spin up IDLE and use AddChart on a
blank document the Excel window appears as normal and does not close.

Frankly clutching at straws, but there was something recently
where -- surprisingly -- using dynamic or static dispatching
made a difference. Might this apply here?

TJG
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to