【发布时间】:2023-01-25 19:55:02
【问题描述】:
我想从 VBA 向 python 发送一个十进制数数组并返回一组。目前我可以从 VBA 宏运行 python 脚本并向它传递字符串参数,但我不能发送数组。
我已经研究过其他方法来做到这一点,但似乎无法找到任何其他方法。此外,我正在尝试远离付费软件,如 PyXll 或类似软件。
我比 Python 更熟悉 VBA,所以我更喜欢在 Python 中工作,只使用 VBA 发送和接收 CSV 文件的数据 这是我到目前为止所得到的,
Pythonexe = """C:\ ~~~ \python.exe""" 'path of the python.exe
PythonScript = """C:\ ~~~ \ExcelToPython.py""" 'path of the Python script
Dim ColumnLength As Integer
Dim RowLength As Integer
Dim counter As Integer
counter = 0
For RowLength = 0 To 10
For ColumnLength = RowCounter
PythonArg(counter) = (ThisWorkbook.Worksheets("location sort").Cells(ColumnLength, RowLength))
counter = counter + 1
Next ColumnLength
objShell.Run Pythonexe & PythonScript & PythonArg
counter = 0
Next RowLength
我试图让这个尽可能简单,因为我将在几台不同的机器上运行。 任何帮助,将不胜感激。
【问题讨论】: