User defined functions through Automation in Excel 2003

jpgreenwald at gmail.com jpgreenwald at gmail.com
Sun Sep 3 04:01:42 EDT 2006


Hi all,

Im trying to create user defined functions (ones that you can use in
the cells of excel) in python.  I know that its a ...dumb... thing to
do since its a lot easier in other languages (vb,c#, vc..etc) but Im
stuck on seeing if I can get this to work.  Currently I have written a
simple script:

class jtest:
    _public_methods_ = ['Add2']
    _reg_clsid_ = "{27A888AA-B5DB-44BE-BBA7-DECF3A1DF861}"
    _reg_progid_ = "jtest.Excel"

    def Add2(x, y):
        return x+y

and compiled it to a dll with py2exe and created the registry entry in

HKCR\CLSID\{xxxGUIDxxx}\Programmable\

so that excel can pick it up and it loads no problem when selecting it
from the automation add-in menu.  However thats all it does.  I cant
seem to be able to call the function or do anything with it.  Im sure
there is a lot more thats needed than what im doing but documentation
is scarce.  Thanks for any help or insight that can be offered.

-Jesse




More information about the Python-list mailing list