Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I call python program from VBA?

Tags:

python

vba

Just as the title goes.

I have a python program which processes some data file I downloaded from email.

I am writing a vba script which can download the email attachments and execute the python program to process the email attachments, such that I can automate my daily job.

Any idea?

like image 771
lamwaiman1988 Avatar asked Nov 01 '11 07:11

lamwaiman1988


1 Answers

One way to do that is to turn your Python code into a COM Server and then access it like any other COM object. This chapter from Python Programming on Win32 shows how simple it can be. The rest of the chapter gets into a lot of technical details that are probably not necessary for your application. Just turn your Python code into a class, expose one method for the VBA to call it, and that should do the trick.

like image 188
Michael Dillon Avatar answered Sep 20 '22 22:09

Michael Dillon