On 17/07/2012 14:51, Kurt Munson wrote:
> I have been using pywin32 successfully for years to control Excel.  Now,
> suddenly I get errors executing the same code that has run previously.

[...]

> The last line(‘xl.visible = 0’) now causes an error:

[...]

> This error goes away if I use xl.Visible instead of xl.visible – notice
> the uppercase V.  But then I get all sorts of other errors, in places
> that didn’t error previously.


You've almost certainly switched from using dynamic (or late-binding)
Dispatch to using static (or early-binding) Dispatch. Dynamic dispatch
simply hands off all attribute access to the underlying COM object which
is not case-sensitive. Static dispatch creates an actual Python module
which -- like all Python code -- is case-sensitive.

You can force dynamic dispatch by using:

<code>
import win32com.client

xl = win32com.client.dynamic.Dispatch("Excel.Application")

</code>

Apart of the case-sensitivity, BTW, the clue is also in the traceback
you posted which includes the win32com.gen_py prefix, indicating that
it's using a generated Python module.

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

Reply via email to