Me and Tim started to email each other directly, here are the messages for
anyone who is interested.

~Tom

---------- Forwarded message ----------
From: Tom <t...@pentest.7safe.com>
Date: Fri, Aug 26, 2011 at 12:04 PM
Subject: Re: [python-win32] Issue with inserting Microsoft Excel charts into
Word
To: Tim Golden <m...@timgolden.me.uk>


Thank you so much for your help, I really appreciate it.
I'm really not sure what the issue is, but I have it working now. I changed
DispatchEx to EnsureDispatch and I changed the WorkSheets call (Which
apparently doesn't exist on server 2003) to ActiveSheet and this went
through fine.

I expect me not knowing why this happened will come back to bite me soon
enough, but its working now.

~Tom


On Fri, Aug 26, 2011 at 11:50 AM, Tim Golden <m...@timgolden.me.uk> wrote:

> On 26/08/2011 11:42, Tom wrote:
>
>> Ok, this is weird. I think you were right Tim:
>> I tried running makepy on all the libraries I thought I would need, and
>> that didn't work. So I just copied all the gen_py files to the server
>> and re-ran the report generation. This seemed to produce a different
>> error - instead of not finding the Chart object it now does, but it
>> errors because excels workbook object (_workbook) doesn't have a
>> WorkSheets attribute (worksheet = chart.ChartData.Workbook.**
>> WorkSheets(1)).
>>
>> Can you explain more about dynamic and static dispatching, can I force
>> win32com to do one or the other?
>>
>
> It's a concept basically invented by Mark Hammond when he created
> the Python bindings to COM -- ie it's not COM terminology as such.
>
> By good fortune, the (slightly ancient but still relevant) book
> on Python Win32 has a sample chapter which covers this stuff:
>
>  
> http://oreilly.com/catalog/**pythonwin32/chapter/ch12.html<http://oreilly.com/catalog/pythonwin32/chapter/ch12.html>
>
> In short, though, the win32com modules will either generate
> a temporary wrapper around the IDispatch-interfaces objects;
> or will generate an actual Python module which is squirrels
> away under the gen_py directory.
>
> The most notable difference is that the former simply passes
> everything it can through to the underlying COM objects,
> which are case-insensitive, while the latter uses Python
> module which is therefore case-sensitive. So this code:
>
> xl = win32com.client.Dispatch ("Excel.Application")
> xl.visible = 1
>
> will work if the xl object has been dynamically dispatched
> (the default) but will fail if it's statically dispatched
> because the documented attribute is actually Visible with
> an initial cap.
>
> To force one or another:
>
>  xl = win32com.client.dynamic.**Dispatch ("Excel.Application")
>
> for dynamic; or
>
>  xl = win32com.client.gencache.**EnsureDispatch ("Excel.Application")
>
> for static.
>
> HTH
>
> TJG
>
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to