I am trying to run a python script in excel VBA like this:
Shell("python " & ActiveWorkbook.Path & "\CreateVolsurface.py -d ""10 Sep 12""")
but it does nothing. If I watch the task manager, a python process doesn't even get created. If I debug and copy the string created in the code above and paste it into command prompt it runs perfectly.
The python script takes a date (as a string) as a parameter and creates an image file.
Any idea why this would not work or how I could debug it?
I've also tried this:
Shell ("python CreateVolsurface.py -d ""10 Sep 12""")
and this:
ret_val = Shell("python " & ActiveWorkbook.Path & "\CreateVolsurface.py -d ""10 Sep 12""", vbHide)
but they also do nothing.
The issue was that shell() in vba starts cmd.exe in it's default folder and not in the active folder of the current workbook. In my python script I had relative path references which was an issue. To solve this I used the os module in my python script to change the current directory at the start.