6

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?

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

1
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" 

2 Comments

Doesn't work. Do you realize we need to type "python somecode.py" to make a python code run in cmd?
Yes. Make sure that Python.exe is in your path & give the full path in case of any doubts. For e.g. c:\Python30\Python.exe someargument

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.