title: Getting "method not valid without suitable object" error when trying to make a HTTP request in VBA?
body: <p>I tried to follow this example: <a href="http://libkod.info/officexml-CHP-9-SECT-5.shtml" rel="noreferrer">http://libkod.info/officexml-CHP-9-SECT-5.shtml</a> - <a href="https://web.archive.org/web/20151230075839/http://libkod.info/officexml-CHP-9-SECT-5.shtml" rel="noreferrer">Archive.org</a> - <a href="https://archive.org/donate/" rel="noreferrer">Donate</a></p>
  <p>but it gave this error</p>
  <p><img src="https://i.imgur.com/c61zb4A.png" alt="Imgur" /></p>
  <p>on this line:</p>
  <pre><code>Dim objHTTP As New MSXML2.XMLHTTP
  </code></pre>
  <p>I tried to use this example: <a href="https://stackoverflow.com/questions/158633/how-can-i-send-an-http-post-request-to-a-server-from-excel-using-vba">How can I send an HTTP POST request to a server from Excel using VBA?</a></p>
  <p>but it gave this error:</p>
  <p><img src="https://i.imgur.com/9LuHTHb.png" alt="Imgur" /></p>
  <p>on this line:</p>
  <pre><code>Print objHTTP.Status
  </code></pre>
  <p>So how do I make a POST REST call in VBA? How do I make a PUT multi-part/form-data file upload REST call in VBA?</p>
  <h3>Tools &gt; References</h3>
  <p><img src="https://i.imgur.com/4pBaz7O.png" alt="Imgur" /></p>
  <h3>Code</h3>
  <pre><code>Sub SendEmail()
      'Dim objHTTP As New MSXML2.XMLHTTP
      'Set objhttp = CreateObject(&quot;WinHttp.WinHttpRequest.5.1&quot;)
      Set objHTTP = CreateObject(&quot;MSXML2.ServerXMLHTTP&quot;)
      URL = &quot;http://localhost:8888/rest/mail/send&quot;
      objHTTP.Open &quot;POST&quot;, URL, False
      objHTTP.send (&quot;{&quot;&quot;key&quot;&quot;:null,&quot;&quot;from&quot;&quot;:&quot;&quot;me@me.com&quot;&quot;,&quot;&quot;to&quot;&quot;:null,&quot;&quot;cc&quot;&quot;:null,&quot;&quot;bcc&quot;&quot;:null,&quot;&quot;date&quot;&quot;:null,&quot;&quot;subject&quot;&quot;:&quot;&quot;My Subject&quot;&quot;,&quot;&quot;body&quot;&quot;:null,&quot;&quot;attachments&quot;&quot;:null}&quot;)
      Print objHTTP.Status
      Print objHTTP.ResponseText
      
  End Sub
  </code></pre>
  <h3>Reference</h3>
  <p>WinHttpRequest object: <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa384106(v=vs.85).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/windows/desktop/aa384106(v=vs.85).aspx</a></p>