VBA - Calling a .bat file or Python Script

jonnyk26

New Member
Joined
Mar 19, 2008
Messages
1
Hi,

I'm banging my head against the wall here! I'm trying to use Excel to generate and instruction file for Python to run some complex calculations. Problem is, I can't get my Python script to run through VBA.

I've used variations of the 'Shell' command:
ie: Call Shell ("xxx", 1), Call Shell ("xxx"), Call Shell "xxx", Shell ("xxx", 1), Shell ("xxx"), Shell "xxx", etc.

As well, I have tried different string commands inside the Shell function:
Shell ("cmd") gives me the DOS Shell (in the C:\WINDOWS directory)
Shell ("cmd /c python") gives me the Python Shell
Shell ("cmd /c python myfile.py") doesn't do anything

With regards to the .bat file, I have also tried calling that to invoke Python by methods such as this:
Shell ("e:\myfile.bat")
Shell ("myfile.bat")

Anyway, nothing seems to be working for me. Please help! Thanks in advance...
 
This code runs a .BAT file called TEST.BAT
Code:
rsp = Shell(Environ$("COMSPEC") _
& " /c C:\TEMP\TEST.BAT", vbNormalFocus)
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top