开发者

Sending data from excel to Server using HTTP Post

开发者 https://www.devze.com 2023-03-12 07:52 出处:网络
How can I send data to Server from excel using HTTP Post? Lets say the URL is: http://testingHttpPost/开发者_JS百科

How can I send data to Server from excel using HTTP Post?

Lets say the URL is: http://testingHttpPost/

开发者_JS百科

And I want to send data from Cells A2 and B2. How would I get this done in VBA?

Thanks in advance


Sub XMLPost()
Dim xmlhttp, sData As String

    With ActiveSheet
        sData = "x=" & URLencode(.Range("A2").Value) & _
                "&y=" & URLencode(.Range("B2").Value)
    End With

    Set xmlhttp = CreateObject("microsoft.xmlhttp")

    With xmlhttp
        .Open "POST", " http://testingHttpPost/", False
        .setrequestheader "Content-Type", "application/x-www-form-urlencoded"
        .send sData
        Debug.Print .responsetext
    End With
End Sub

For URLencode function see here: How can I URL encode a string in Excel VBA?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号