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?

lamwaiman1988
  • 3,729
  • 15
  • 55
  • 87

2 Answers2

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.

David Zemens
  • 53,033
  • 11
  • 81
  • 130
Michael Dillon
  • 31,973
  • 6
  • 70
  • 106
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" 
shahkalpesh
  • 33,172
  • 3
  • 63
  • 88
  • 1
    Doesn't work. Do you realize we need to type "python somecode.py" to make a python code run in cmd? – lamwaiman1988 Nov 01 '11 at 07:18
  • 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` – shahkalpesh Nov 01 '11 at 09:54