Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile a Python module to dll and call it in VBA

Tags:

python

vba

dll

I want to create a user defined function written in Python. Then I want to compile it to a dll, and distribute it and call in EXCEL vba on another computer which doesn't have python installed.

For example, I want to create a function in Python:

def add(a,b): return a+b

Then, compile it and export it as a dll. On another computer without Python, I can to import this function in EXCEL vba and use it. How to do it?

Thanks,

like image 889
user2662434 Avatar asked Aug 09 '16 14:08

user2662434


1 Answers

in excel go to the vbe editor Tools>References browse your dll and add a reference, this will make available your dll functions in vba.

as per making it a dll, look what jb suggest here How to compile a Python package to a dll and follow the comments on that as well.

another option would be like stated here https://code.google.com/archive/p/shedskin/

like image 81
Sol Stein Avatar answered Oct 25 '22 06:10

Sol Stein