I wrote a Python code that performs some calculations using as input data in an excel workbook. My goal is to add a button inside the input excel workbook that automatically run the python script. I have already added the button to which I've associated the following macro:
'''
Sub RunPythonScript()
Dim objShel As Object
Dim PythonExe, PythonScript As String
Set objShell = VBA.CreateObject("Wscript.Shell")
PythonExe = "*path to python.exe*"
PythonScript = """*path to the code*"""
objShell.Run PythonExe & PythonScript
End Sub
'''
The macro isn't working and returns the error Method 'Run' of object IWshShell3 failed! I don't know if the issue is due to the fact that I have the input excel workbook for the python code open (usually should be closed to make the code works).