Sub CallXlwings()
RunPython "import my_script; my_script.main('argument_value')"
End Sub
Use code with caution.Python Syntax: Use xw.Book.caller() to refer back to the workbook that called the script.
Key Implementation Details
Handling Spaces: If your file paths have spaces, you must wrap them in triple double-quotes (e.g., """C:\My Folder\script.py""") to prevent the shell from breaking the path into multiple arguments.
Waiting for Completion: Setting the third parameter of objShell.Run to True forces VBA to pause until the Python script closes.
Environment: If you are using a virtual environment (like Anaconda), ensure the PythonExe path points to the specific python.exe within that environment's folde