Guten Tag liebe Community,
ich habe heute eine Frage, die auch etwas mit Python zu tun hat. Ich hoffe mir kann jemand helfen. Ich möchte ein Tool entwickeln, bei dem es nötig ist ein Python Skript über VBA zu starten. Dafür habe ich im Internet folgenden Code-Abschnitt gefunden:
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
Dieser Code funktioniert bei mir auch prima. Allerdings hab ich das Problem, dass wenn ein Kollege das Tool von seinem Computer aus startet, dass es dann nicht funktioniert. Ich glaube, dass ich bei "PythonExePath" einen zu spezifischen Pfad eingetragen habe, und zwar: "C:\Users\Sven\Python38-32\Python\Python.exe". Gibt es eine Möglichkeit, wie ich anstelle solch eines Pfades einen anderen Pfad eintragen der etwas allgemeiner ist und bei jedem Anwender funktioniert ?
|