Differences between revisions 6 and 12 (spanning 6 versions)
Revision 6 as of 2005-11-15 21:58:39
Size: 2100
Editor: c-66-31-1-125
Comment:
Revision 12 as of 2017-11-24 16:26:15
Size: 409
Editor: MilanTempl
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Description =
Typically when dealing with 3rd party COM libraries (eg. Office), you make use
of the constants defined in that library. Once makepy creates the typelib for
you, using these constants is normally easy in python. You only need to
import win32com.client.constants to access them.

However, since these typelibs aren't really imported, py2exe needs to be told
to include them in your setup-script.

= Solution 1 =
Here's how I'm importing the typelib for Excel XP:

setup.py:
{{{
#!python
 ...
 setup(
        ...,
        options = {"py2exe": {"typelibs": [('{00020813-0000-0000-C000-000000000046}',0,1,4)]}},
        ...
      )
}}}
So, as you can see, it's an option in the options dictionary, containing a
list of the typelibs you need. Each typelib being represtented as a
tuple of (CLSID, LCID, MajorVersion, MinorVersion) - all of which numbers you
can find in the typelib file itself.

You can print out these magic numbers by running the {{{makepy}}} script with the {{{-i}}} command line option.

= Solution 2 =

That solution was the easier one for py2exe 0.4, but it still works:

{{{
cd \python23\Lib\site-packages\win32com\client
python makepy.py -o {MyProjectDirectory}\OLE_Excel10.py
}}}

within the software change:

{{{
#!python
import win32com.client
o = win32com.client.Dispatch("Excel.Application")
o.Method()
o.property = "New Value"
print o.property
}}}
(taken from M. Hammonds documentation "Quick Start to Client side COM and Python")

to

{{{
#!python
import OLE_Excel10 as Excel
_ec=Excel.constants

o = Excel.Application()
o.Method()
o.property = "New Value"
print o.property
}}}



I believe that Solution 2 is not correct. It will work if you happen to be on a machine that has python installed, but if your goal is to use py2exe to distribute an application to machines that don't have python (and win32com) installed, then I don't think it will work. What the py3exe stuff in Solution 1 does is incorporate the generated win32com wrappers into the py2exe stuff.
-Alec Wysoker
I'm a 33 years old, married and study at the university (Asian Studies).<<<BR>>
><<<BR>>
>
In my free time I teach myself French. I've been there and look forward to returning sometime near future. I love to read, preferably on my kindle. I like to watch Bones and Psych as well as documentaries about nature. I love Swimming.<<<BR>>
><<<BR>>
>
<<<BR>>
><<<BR>>
>
my web-site: [[https://yt.ax|YT]]

I'm a 33 years old, married and study at the university (Asian Studies).<
><
> In my free time I teach myself French. I've been there and look forward to returning sometime near future. I love to read, preferably on my kindle. I like to watch Bones and Psych as well as documentaries about nature. I love Swimming.<
><
> <
><
> my web-site: YT

IncludingTypelibs (last edited 2017-11-26 01:33:30 by JimmyRetzlaff)