如何将VBA输出发送到Python脚本?

这是一个代码片段:

' Send the query in the body to Jira, and get the response from Jira strJsonResponse = Utilities.JiraRequest(strJQLQuery) 

我想把这个json放入一个Pythonparsing器,然后将parsing的json返回到电子表格中。 这可能吗? 我从来没有使用过VBA。

我已经下载了JIRA API模块和openpyxl模块。

您可能能够创build一个新的文本文件并输出VBA

 Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject") Dim Fileout As Object Set Fileout = fso.CreateTextFile("C:\your_path\vba.txt", True, True) Fileout.Write strJsonResponse Fileout.Close 

VBA代码在这里find

然后让VBA启动你的python脚本,你可以用pythonparsing你的文件。 可能有更好的方法来做到这一点,但我不知道是什么。

我认为Tehscript提出了一个有效的问题。 你确定除了你的Python代码之外还需要使用VBA代码吗? 通过运行使用openpyxl模块的Python代码,您可以读取和修改Excel文件中的所有内容,而无需运行Excel应用程序。

有时,有耦合VBA和Python代码的正确理由。 最常见的是当你想使用Excel作为一个熟悉的graphics用户界面来指导数据操作的操作,但希望Python做实际的繁重工作。 如果你想要这样做,那么就有xlwings模块。 Xlwings可以很容易地从VBA模块中调用Python代码,并在VBA和Python之间交换数据值 。