Steven G
Steven G

Reputation: 17152

how can I create a dll from a simple python code that could be call in VBA

I know this is a a very large question but I'll try to make it as simple as possible.

Assuming that my example.py only holds the following code:

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

How could I encapsulate this into a dll that would be callable without actually having python installed on the end-user computer. My goal is to use it in VBA.

I looked at py2exe that creates a .exe but I can't find a solution for a dll. any help would be appreciated. I use python 3.6

Upvotes: 5

Views: 751

Answers (1)

Conor
Conor

Reputation: 156

Cython (http:cython.org) produces C code from python sources. This generated can be compiled into a dll and called from VBA

Read the section "Using Cython Declarations from C" in the documentation

http://www.google.com/search?q="Using+Cython+Declarations+from+C"+site:cython.org

Upvotes: 2

Related Questions