有没有办法在Excel-VBA中调用python代码? [英] Is there a way to call a python code in Excel-VBA?
问题描述
现在我想让这个python.py在Main.xlsm宏的运行期间执行,然后使用这个xlsx文件。我基本上想减少外部执行python.py的步骤。有没有命令呢?我是VBA的新手。
最简单的方法是运行python解释器与 Shell
命令
Shell(python.exe&&& arguments)
I have an excel file(Main.xlsm) containing macros. I have a python file(python.py) to generate a subsidiary excel file(sub.xlsx) which i would further call in the macros of Main.xlsm file. This sub.xlsx file which is generated by the run of python.py is saved in the same working directory.
Now I want to make this python.py to be executed during the run of the Main.xlsm macros and then use this xlsx file. I basically want to reduce the step of executing python.py externally. Is there a command for that? I am new to VBA.
The simplest way is to run the python interpreter with the Shell
command
Shell ("python.exe " & yourScript & " " & arguments)
这篇关于有没有办法在Excel-VBA中调用python代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!