How can I send an HTTP POST request to a server from Excel using VBA?

前端 未结 6 1900
执笔经年
执笔经年 2020-11-22 08:01

What VBA code is required to perform an HTTP POST from an Excel spreadsheet?

6条回答
  •  有刺的猬
    2020-11-22 08:33

    You can use ServerXMLHTTP in a VBA project by adding a reference to MSXML.

    1. Open the VBA Editor (usually by editing a Macro)
    2. Go to the list of Available References
    3. Check Microsoft XML
    4. Click OK.

    (from Referencing MSXML within VBA Projects)

    The ServerXMLHTTP MSDN documentation has full details about all the properties and methods of ServerXMLHTTP.

    In short though, it works basically like this:

    1. Call open method to connect to the remote server
    2. Call send to send the request.
    3. Read the response via responseXML, responseText, responseStream or responseBody

提交回复
热议问题