I removed the CLSID from setup.py and started using your solution.
I created the 2 files with makepy.

Good news, with Excel2003.py import the dispatch function in win32com.client works for both Excels.

Bad news, I have to use the DispatchWithEvents function with is not in Excel2003.py/Excel2010.py.

I'm not sure the problem is still with py2exe, but do you have any idea to solve the problem ? I mean, successfully import  DispatchWithEvents



On Wed, Jul 11, 2012 at 5:07 PM, Massa, Harald Armin <chef@ghum.de> wrote:

my solution is:

- use makepy.py to create the object librarie for 2003 and 2010; 
- store them in files as excel2003.py, excel2010.py (--name parameter of makepy)
- use this kind of binding, check which Excel is on your computer and do conditional import

if excel_2010_is_present:
   import excel2010 as excel
   import excel2003 as excel 

best wishes
2012/7/11 Mathieu BEAL <mathieu.beal@gmail.com>

I want to create an .exe with py2exe for 2 versions of Excel.
The Excel 2003 is installed on my computer, but users have to use the Excel 2010 version.

Is there a way to create an .exe that uses the correct excel version on my computer and the correct one on the users' computers ?

   data_files = data_files,
    options = {"py2exe": {"compressed": 2,
                          "optimize": 2,
                          "includes": includes,
                          "excludes": excludes,
                          "packages": packages,
                          "dll_excludes": dll_excludes,
                          "bundle_files": 3,
                          "dist_dir": "dist",
                          "xref": False,
                          "typelibs": [('{00020813-0000-0000-C000-000000000046}',0,1,5),
                          "skip_archive": False,
                          "ascii": False,
                           "custom_boot_script": '',

    zipfile = "lib\library.zip",
    #console = [GUI2Exe_Target_1]
    windows = [GUI2Exe_Target_1]

The console gives me the following error:
pywintypes.com_error: (-2147319779, (Bibliotheque non inscrite.' , None, None)

The first Excel CLSID works, the second doesn't . It's normal but how to include both ?



Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Py2exe-users mailing list


Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart

Amtsgericht Stuttgart, HRB 734971