xlwings에서 세팅방법이 번거로웠다!!! 라고 한다면 이 영상을 참고 해보세요!!! 다른세팅은 하지 않고 vba의 쉘을 활용하여 파이썬 파일을 즉시 실행하는 방법입니다.
Sub RunPython()
Dim shell As Object
Dim pythonExePath, pythonScriptPath As String
'파이썬이 설치된 위치
pythonExePath = """C:\Users\juhyun\AppData\Local\Programs\Python\Python311\python.exe"""
'파이썬 코드를 작성한 파일 위치
pythonScriptPath = "C:\Users\juhyun\Desktop\test\excelCode\test.py"
Set shell = CreateObject("WScript.Shell")
shell.Run pythonExePath & pythonScriptPath
Set shell = Nothing
End Sub
Visual Basic
복사