[python-win32] Grabbing an active Excel application
Jens B. Jorgensen
jens.jorgensen@tallan.com
Fri, 16 Aug 2002 11:40:49 -0500
It gets worse. I find that if I have a python open that has a reference
to an Excel.Application object and then I close the Excel window while
python is still running then if I later run Excel the inner frame of the
window gets hung (never paints, shows image of what was behind the
window). I'm sure this is not a python problem per se but a COM one. In
this case I can look at the process manager and find a running
excel.exe. I have to kill that process and then start again to get back
to normal.
Blair Hall wrote:
> Further to my posting yesterday, and Jens' suggestion, I find that
> 'grabbing'
> an existing Excel is still problematic.
>
> Here is __init__ from my class that wants to use Excel
>
> def __init__(self
> , visible=1
> ):
> """
> Create a new file in the current working directory
> and save a new Excel workbook in it.
> """
> try:
> self.__app = win32com.client.Dispatch("Excel.Application")
> self.__app.Visible = visible
> except pythoncom.com_error, e:
> self.__comExceptionHandler(e)
>
> When I instantiate that class the first time, then all
> is fine. ie:
>
> >>> xl = myClass()
>
> However, if I then immediately do something silly like
>
> >>> xl = myClass()
>
> Excel disappears from view (it is still running though). From that point
> on Python and Excel don't seem to be quite able to agree on how
> to interact.
>
> It seems that Jens' suggestion is fine, but in case I am looking for
> a few more idiot-proof safeguards.
>
> By the way, I am working on Win95.
>
>
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32
--
Jens B. Jorgensen
jens.jorgensen@tallan.com
"With a focused commitment to our clients and our people, we deliver value through customized technology solutions"