[Please don't post in html format, use plain text] Jason R. Coombs schrieb: > Using comtypes on 64-bit Python, I get the following error: > > Python 2.6.2 (r262:71605, Apr 14 2009, 22:46:50) [MSC v.1500 64 bit (AMD64)] > on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> import comtypes; comtypes.__version__ > '0.6.0.2dev' >>>> from comtypes.client import * >>>> app = CreateObject('Excel.Application') > # Generating comtypes.gen._00020813_0000_0000_C000_000000000046_0_1_6 > # Generating comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0 > # Generating comtypes.gen.stdole > # Generating comtypes.gen._2DF8D04C_5BFA_101B_BDE5_00AA0044DE52_0_2_4 > # Generating comtypes.gen.Office > # Generating comtypes.gen._0002E157_0000_0000_C000_000000000046_0_5_3 > # Generating comtypes.gen.VBIDE > # Generating comtypes.gen.Excel >>>> app.Workbooks.Open('foo') > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > _ctypes.COMError: (-2147352568, 'Bad variable type.', (None, None, None, 0, > None)) > > If I use 32-bit Python or if I use pywin32 win32com.client.Dispatch on > 64-bit Python, everything behaves as expected (it opens the file or throws > an error saying it can't find the file). I've tried passing u'foo' instead, > but it throws the same error. > > Any suggestions?
It seems comtypes (or ctypes?) on 64-bit Windows still has some severe problems. As a workaround, you could use CreateObject('Excel.Application', dynamic=True), this works for me. For your original code, I get different problems (this is on WinXP Prof. x64, with Office 2003): Python 2.6.2 (r262:71605, Apr 14 2009, 22:46:50) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from comtypes.client import CreateObject >>> xl = CreateObject("Excel.Application") # Generating comtypes.gen._00020813_0000_0000_C000_000000000046_0_1_5 # Generating comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0 # Generating comtypes.gen.stdole # Generating comtypes.gen._2DF8D04C_5BFA_101B_BDE5_00AA0044DE52_0_2_3 # Generating comtypes.gen.Office # Generating comtypes.gen._0002E157_0000_0000_C000_000000000046_0_5_3 # Generating comtypes.gen._2DF8D04C_5BFA_101B_BDE5_00AA0044DE52_0_2_4 # Generating comtypes.gen.VBIDE # Generating comtypes.gen.Excel >>> xl.Workbooks.Add("foo") Traceback (most recent call last): File "<stdin>", line 1, in <module> _ctypes.COMError: (-2146827284, None, (u"'foo.xls' wurde nicht gefunden. \xdcberpr\xfcfen Sie die Rechtschreibung des Da teinamens und \xfcberpr\xfcfen sie, ob der Ort der Datei korrekt ist.\n\nWenn Sie versuchen, die Datei \xfcber die Liste der zuletzt verwendeten Dokumente im Men\xfc 'Datei' zu \xf6ffnen, \xfcberpr\xfcfen Sie dass die Datei nicht umbenannt, verschoben oder gel\xf6scht wurde.", u'Microsoft Office Excel', u'C:\\Program Files (x86)\\Microsoft Office\\OFFICE11\\ 1031\\xlmain11.chm', 0, None)) >>> xl.Workbooks.Add(r"c:\svn\comtypes\foo.xls") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "comtypes\_meta.py", line 13, in _wrap_coclass result = punk.QueryInterface(itf) File "comtypes\__init__.py", line 1074, in QueryInterface self.__com_QueryInterface(byref(iid), byref(p)) ValueError: NULL COM pointer access >>> -- Thanks, Thomas ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users