lamwaiman1988
lamwaiman1988

Reputation: 3742

How can I call python program from 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?

Upvotes: 6

Views: 3298

Answers (2)

Michael Dillon
Michael Dillon

Reputation: 32392

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.

Upvotes: 4

shahkalpesh
shahkalpesh

Reputation: 33476

Shell "path to my python exe"

I am sorry, I haven't used python enough.
Lets say, you want to run .pyc file, it could be

Shell "path to python.exe argumentOfPYCFilePath" 

Upvotes: 1

Related Questions