PythonCOM and Office. Arrgh!

Bill Bell bill-bell at bill-bell.hamilton.on.ca
Tue Jul 10 08:21:12 EDT 2001


Matthew <matthewm at ihug.co.nz> wrote, in part:
> No matter what I try, I CAN NEVER get named keyword arguments to do
> anything via PythonCOM Excel automation.
> 
> xlapp.Workbooks.Open("D:\\Fred.xls", Password='fred')
> profers no error. The xcel window opens with Password Dialog  opem.
> Type in 'fred' and s/s loads up. Named arg passed in call apparently
> ignored.
> 
> xlapp.Workbooks.Open("D:\\Fred.xls", password='fred')
> generates error - Open got unexpected keyword argument 'password', so
> it seems to me that somethings going on with passed named args

Unfortunately, about all I can say at this point (gotta go to a 
meeting) is that there is something I don't understand. I've tried to 
use late binding, as outlined in the Hammond-Robinson book, 
hoping that the case of the named password would disappear as a 
problem. No such luck.

xlapp = win32com.client.dynamic.Dispatch('Excel.Application')
>>> xlapp.Workbooks.Open(r'C:\0 Query responses\Book1.xls', 
password=r'seamus')
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
TypeError: Open() got an unexpected keyword argument 'password'

Tried running makepy, again on the advice of the book, hoping that 
this would enable pycom to handle the argument successfully. No 
go.

That book does suggest getting one's hands dirty with lower-level 
calls. Haven't time to try any of that.

Would be interested in knowing what you find out. Good luck.

Bill




More information about the Python-list mailing list