关于xlwings,API为ExcelVBA使用Python
About xlwings, the API for Excel VBA to use Python
当我按照 xlwings 的说明进行操作时:
Sub MyMacro()
RunPython ("import mymodule; mymodule.rand_numbers()")
End Sub
它给我这样的错误:找不到我的模块。我的理解是这应该是来自 xlwings 的对象。
为什么 Excel 找不到它,我应该如何更正这个错误?
将 PYTHONPATH
设置为 mymodule
所在的文件夹。默认情况下,它希望它与您的 Excel 文件位于同一目录中,请参阅 docs.
当我按照 xlwings 的说明进行操作时:
Sub MyMacro()
RunPython ("import mymodule; mymodule.rand_numbers()")
End Sub
它给我这样的错误:找不到我的模块。我的理解是这应该是来自 xlwings 的对象。
为什么 Excel 找不到它,我应该如何更正这个错误?
将 PYTHONPATH
设置为 mymodule
所在的文件夹。默认情况下,它希望它与您的 Excel 文件位于同一目录中,请参阅 docs.