Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTPS POST request using VBA for Excel

I use "WinHttp.WinHttpRequest.5.1" to send HTTP POST requests from VBA in Excel. But I could not manage to do it for HTTPS, as I received an SSL certificate error.

What VBA code would you use to negotiate an SSL connection to a website from VBA in Excel ?

like image 278
afewcc Avatar asked Aug 12 '09 05:08

afewcc


People also ask

Can Excel VBA pull data from a website?

You can use VBA to extract data from web pages, either as whole tables or by parsing the underlying HTML elements. This blog shows you how to code both methods (the technique is often called "web-scraping").

Can VBA send Gmail?

Sending an email through Gmail with VBA is easy once you know the correct Gmail SMTP server and port information. After configuring your message using the Microsoft CDO library, your macro will be ready to send.

Can Excel VBA send emails?

In VBA, to send emails from Excel, we can automatically automate our mailing feature to send emails to multiple users at a time. However, to do so, we need to remember that we may do it by outlook, another product of outlook, so we need to enable outlook scripting in VBA. Once done, we use the .


1 Answers

The WinHttpRequest object has a SetClientCertificate method. Try this code example taken from the MSDN (I tried to adapt it for VBA):

' Instantiate a WinHttpRequest object. '
Dim HttpReq as new ActiveXObject("WinHttp.WinHttpRequest.5.1")

' Open an HTTP connection. '
HttpReq.Open("GET", "https://www.test.com/", false)

' Select a client certificate. '
HttpReq.SetClientCertificate("LOCAL_MACHINE\Personal\My Certificate")

' Send the HTTP Request. '
HttpReq.Send()
like image 137
Treb Avatar answered Oct 03 '22 00:10

Treb