PythonCOM and Office. Arrgh!

Bill Bell bill-bell at bill-bell.hamilton.on.ca
Tue Jul 10 15:31:05 EDT 2001


"Emile van Sebille" <emile at fenx.com> wrote, in part:
> This worked for me.  Win2ksp1, excel2k, Python 2.1
> 
> >>> import win32com.client
> >>> xl = win32com.client.Dispatch("Excel.Application")
> >>> xlc = win32com.client.constants
> >>> xl.Workbooks.Open('test',Password='fred')
> <COMObject Open>
> >>> xl.Visible=1
> 
> What do you get when you try this?

Using Win95, Excel 97 SR-1, Python build 203

>>> import win32com.client
>>> xl = win32com.client.Dispatch("Excel.Application")
>>> xlc = win32com.client.constants
>>> xl.Workbooks.Open(r'C:\0 Query 
responses\Book1.xls',Password='seamus')
---- At this point MS Excel displayed itself with a password dialogue
---- I cancelled that dialogue
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "c:\python21\win32com\gen_py\00020813-0000-0000-C000-
000000000046x0x1x2.py", line 13643, in Open
    ret = self._oleobj_.InvokeTypes(0x2aa, LCID, 1, (9, 0), ((8, 1), 
(12, 17), (12, 17), (12, 17), (12, 17), (12, 17), (12, 17), (12, 17), (12, 
17), (12, 17), (12, 17), (12, 17), (12, 17)),Filename, UpdateLinks, 
ReadOnly, Format, Password, WriteResPassword, 
IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, 
Converter, AddToMru)
com_error: (-2147352567, 'Exception occurred.', (1004, 'Microsoft 
Excel', 'Open method of Workbooks class failed', 'XLMAIN8.HLP', 
0, 0), None)
>>> xl.Visible=1
---- At this point MS Excel again displayed itself

This seems to be what the thread's originator experienced. 
Tentatively, appears to relate to version or configuration.




More information about the Python-list mailing list