5

I have a code in VBA that worked perfectly for a long time. Suddenly it stopped working for no reason. Nothing has changed on my side.

I use it to download web pages and store them in strings like this:

Function something() As String
URL = "www..."
Set XMLHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
XMLHTTP.Open "GET", URL, False
XMLHTTP.send
something = XMLHTTP.responseText
End Function

at XMLHTTP.send I get the following error: Run-time error '-2147012739 (80072f7d)': An error occurred in the secure channel support

Whats is the meaning of this error and what can be done?

I tried reading about it but it seems that its a generic error and could be many things. Perhaps Microsoft changed some protocols or something similar?

David912
  • 378
  • 1
  • 2
  • 11
  • 1
    So this is an HTTPS url? Perhaps the server has changed from SSL3 to TLS or an updated TLS version, try: http://stackoverflow.com/questions/35089900/winhttp-winhttprequest-5-1-does-not-work-with-paypal-sandbox-after-tls-1-2 – Alex K. May 18 '17 at 10:34
  • Thanks Alex, yes it is HTTPS url and I followed your link. It says to add (XMLHTTP.option(9) = 128) when creating winHttp object but sadly it did not solve the problem – David912 May 18 '17 at 10:56
  • 1
    Plug the host name into https://www.ssllabs.com/ssltest/ run the test, what is listed in the protocols section? (ssl/tls etc). What version of windows are you running? – Alex K. May 18 '17 at 11:19
  • protocol: TLS 1.2 , Windows 7 Professional SP1 – David912 May 18 '17 at 11:31
  • 2
    So you need TLS1.2 enabled at the OS level, try this config tool: https://www.nartac.com/Products/IISCrypto/Download if no joy then this https://support.microsoft.com/en-gb/help/3140245/update-to-enable-tls-1.1-and-tls-1.2-as-a-default-secure-protocols-in-winhttp-in-windows (you may still need to tweak .option(9)) – Alex K. May 18 '17 at 11:33
  • I followed the instructions on microsoft site but there is no change. At least now I understand the problem so I have some sense of direction on what to look for and I will try this config tool as well. Do you think that upgrading the OS will help solving the problem? – David912 May 18 '17 at 12:35
  • I have the exact same problem on my Windows 7 machine. The ssllabs.com/ssltest says TLS 1.2, which I have enabled. Not sure what the option(9) thing is, but that didn't work either. The script runs fine on my Windows 10 machine at work. Any other ideas? – user3925803 Jul 15 '17 at 11:48

1 Answers1

8

I had this same error: 6/30/2018

I'm running Excel on windows 7,

On a Mac, In Parallels.

This was a very simple fix.

Goto Control Panel,

Click Network and Internet,

Click Network and Sharing Center, (at the Bottom Left CLICK Internet Options)

Internet Properties Dialog Box will come up, Click the Advanced Tab

Scroll to bottom and turn on "Use TLS1.2" (Mine was already Set Prior to receiving the Error) Click Apply

Here is the link to the downloads need for the proper Windows OS Update file: http://www.catalog.update.microsoft.com/search.aspx?q=kb3140245

I downloaded and Installed the UpDate from Windows Explorer (File Manager) Restarted Windows

and ran the VBA. It ran perfectly

Thanks to Srinath Gudimetla see his link is below for full details: https://www.linkedin.com/pulse/working-vba-tls-protocol-srinath-gudimetla

KarlH7
  • 91
  • 1
  • 3
  • Thank you very much, I cannot believe this was my problem! Please note that a reboot is mandatory even when you don't need the OS update. – Kar.ma Jul 16 '20 at 16:09
  • thank you so much. it works. I just don't understand why windows devs do such default setups to waste tons of hours of their users. – AdrianHou Jul 26 '20 at 14:27