By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,965 Members | 2,043 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,965 IT Pros & Developers. It's quick & easy.

Run a Python script via Excel/VBA

P: 1
Hi everyone-I've been trying to find a solution to this problem for ages. I have some python scripts that need to be updated regularly and would like to be able to use a macro to accomplish this. Right now I double click the files and they execute via Shell

Expand|Select|Wrap|Line Numbers
  1. Sub RunPyScript()
  3. Dim Ret_Val As Variant
  4. Dim command As String
  6. command = Chr(34) & "C:\Users\Jon Doe\python.exe" & Chr(34) & " " & Chr(34) & "C:\Users\Jon Doe\" & "\" & Chr(34)
  7. Ret_Val = Shell(command, vbNormalFocus)
  9. End Sub

When I attempt to run the above macro, it looks as though it will run the same as when I double click, but Shell exits before the script is executed. If anyone has any ideas on how I can get Shell to remain open until the script is finished, I would greatly appreciate it.
May 19 '18 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.