Microsoft 365 and Office | Development | Other
Building custom solutions that extend, automate, and integrate Microsoft 365 apps.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
How Can I run python script from word add-in?
Building custom solutions that extend, automate, and integrate Microsoft 365 apps.
It looks like you can invoke python utilizing VBAs Shell function (as seen in https://stackoverflow.com/questions/3815340/running-python-scripts-from-ms-office). I don't believe there is a Microsoft Word Add-in that can do this so you may have to resort to the script below.
Sub RunExternalProg()
Dim return_value As Double
return_value = Shell("C:\PathToPython\pythonw.exe C:\my_script.py", vbHide)
Debug.Print return_value
End Sub
(Answer by mechanical_meat)
------------------------------------
If this is helpful please accept answer.