我希望我可以使用一些宏来通过工作电报发送仪表板摘要文本。我知道我通过电报发送webhook(GET和POST html),我在这里研究并发现了这个主题: How can I send an HTTP POST request to a server from Excel using VBA?
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
URL = "https://api.telegram.org/bot<token>/METHOD_NAME"
objHTTP.Open "POST", URL, False
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHTTP.send("")
更换&lt;令牌&gt;和&lt; Method_name&gt;
https://core.telegram.org/bots/api
但是,当我调试代码时,它会锁定excel并且不再返回。知道那可能是什么吗?
答案 0 :(得分:0)
当我将MSXML2.ServerXMLHTTP部署到MSXML2.ServerHTTP60时,它工作正常。
Sub fff()
Set objHTTP = CreateObject("MSXML2.ServerHTTP60")
URL = "https://api.telegram.org/bot<token>/sendMessage?chat_id="id"&text=test"
objHTTP.Open "POST", URL, False
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHTTP.send ("")
Cells(1, 1).Value = objHTTP.ResponseText
End Sub