VBA 调用 Python 函数

发布时间 2024-01-03 20:50:21作者: Cloudhan

python

import xlwings as xw
def test_vba():
    wb = xw.Book.caller()
    sht = wb.sheets[0]
    sht.range('A1').value = '看到我了吗?'

VBA

Sub test_vba()
    RunPython ("from test import test_vba;test_vba()")
End Sub

参考:https://zhuanlan.zhihu.com/p/282110033