Run a Python script via Excel/VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chisox721
    New Member
    • May 2018
    • 1

    Run a Python script via Excel/VBA

    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

    Code:
    Sub RunPyScript()
    
    Dim Ret_Val As Variant
    Dim command As String
    
    command = Chr(34) & "C:\Users\Jon Doe\python.exe" & Chr(34) & " " & Chr(34) & "C:\Users\Jon Doe\" & "\Roto.py" & Chr(34)
    Ret_Val = Shell(command, vbNormalFocus)
    
    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.
Working...