How To Execute A Python Script From Excel Using VBA | Step-by-Step Tutorial [EASY]

Publicado el: 27 July 2020
en el canal de: Sven Bosau
98,983
1.5k

👉 Learn Excel Automation with Python: https://pythonandvba.com/excel-automa...

𝗗𝗘𝗦𝗖𝗥𝗜𝗣𝗧𝗜𝗢𝗡
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
In this tutorial, I will show you, how to execute a Python script from Excel by using VBA.
If you do not have any experience in VBA, do not worry. To run a python script in VBA is very easy and I will explain every step.

Download the Excel File (incl. VBA code) & the Python Script of this video here [Google Drive]:
► http://bit.ly/3usrDoZ

To execute a Python script from Excel using different virtual environments [which also works on macOS], feel free to check out the following tutorial:
►    • Combine Excel & Python | Execute a Python ...  


🚩 Please find below the VBA Code:
_____________________________________________________________

Sub RunPythonScript()

Dim objShell As Object
Dim PythonExePath as String, PythonScriptPath As String
ActiveWorkbook.Save
ChDir ActiveWorkbook.Path

Set objShell = VBA.CreateObject("Wscript.Shell")

'PythonExePath = """ Insert Path to Python EXE here """
'PythonScriptPath = """ Insert Path to Python SCRIPT here """

objShell.Run PythonExePath & PythonScriptPath

End Sub
_____________________________________________________________

𝗖𝗢𝗡𝗡𝗘𝗖𝗧 𝗪𝗜𝗧𝗛 𝗠𝗘
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
🔗 LinkedIn:   / sven-bosau  
📬 Contact: https://pythonandvba.com/contact

☕ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲?
If you want to support this channel, you can buy me a coffee here:
▶ https://pythonandvba.com/coffee-donation


En esta página del sitio puede ver el video en línea How To Execute A Python Script From Excel Using VBA | Step-by-Step Tutorial [EASY] de Duración hora minuto segunda en buena calidad , que subió el usuario Sven Bosau 27 July 2020, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 98,983 veces y le gustó 1.5 mil a los espectadores. Disfruta viendo!