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

Veröffentlicht am: 27 July 2020
auf dem Kanal: 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


Auf dieser Seite können Sie das Online-Video How To Execute A Python Script From Excel Using VBA | Step-by-Step Tutorial [EASY] mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Sven Bosau 27 July 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 98,983 Mal angesehen und es wurde von 1.5 tausend den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!