(Solved) – VBA: -2147012739: An error occurred in the secure channel support

(solved)-–-vba:-2147012739:-an-error-occurred-in-the-secure-channel-support

My Excel VBA code calls two different servers using CreateObject("Msxml2.XMLHTTP.6.0") object. When I execute VBA code in my machine (Windows 10 and Office 2019) I do not receive any error while calling both servers. I have another laptop (Windows 7 and Office 2013), on this laptop I can successfully make call to server one but when calling other server I receive error “-2147012739: An error occurred in the secure channel support” in VBA macro.

This is a critical issue for me, as my client have reported the same error on their machines. I am not aware of the configuration on client’s machine and absolutely have no control to change any config on their machines.

The only option I have to resolve this error is using VBA. Please help.

Note: I already have “Use TLS1.2” option selected in Internet Properties but I still get above error.

Code that works on both PCs:

Sub WORKING()
    Dim objHTTP As Object
    Dim reqJson As String
    Dim URL As String

    reqJson = "{""requestData"":{""actionDetails"":[{""templateName"":""TrialProjects"",""envAlias"":""DEV2"",""userName"":""amy.marlin"",""loggerSheetName"":""SL_Dbg_123"",""buttonClicked"":""Create Projects""}]}}"
    URL = "https://simplifiedloader01.com/COM_UserValidation/requestProcessor"

    Set objHTTP = CreateObject("Msxml2.ServerXMLHTTP.6.0")
    objHTTP.setTimeouts 0, 0, 0, 0
    objHTTP.Open "POST", URL, False

    objHTTP.setProxy 0, "", ""
    objHTTP.setRequestHeader "Content-Type", "application/json"
    objHTTP.setRequestHeader "CharSet", "charset=UTF-8"
    objHTTP.setRequestHeader "Content-Length", Len(reqJson)
    objHTTP.setRequestHeader "Connection", "Keep-Alive"
    objHTTP.Send (reqJson)
    MsgBox objHTTP.responseText
End Sub

Code that works only on Windows 10:

Sub NOTWORKING()
    Dim G_HTTP_Connection_Obj As Object
    Dim reqJson As String
    Dim URL As String

    reqJson = ""
    URL = "https://adc2-zkuh-fa-ext.oracledemos.com/xmlpserver/services/ExternalReportWSSService?WSDL"

    Set G_HTTP_Connection_Obj = CreateObject("Msxml2.ServerXMLHTTP.6.0")
    G_HTTP_Connection_Obj.setTimeouts 0, 0, 0, 0
    G_HTTP_Connection_Obj.Open "POST", URL, False

    G_HTTP_Connection_Obj.setProxy 0, "", ""
    G_HTTP_Connection_Obj.setRequestHeader "Content-Type", "application/soap xml"
    G_HTTP_Connection_Obj.setRequestHeader "CharSet", "charset=UTF-8"
    G_HTTP_Connection_Obj.setRequestHeader "Content-Length", Len(reqJson)
    G_HTTP_Connection_Obj.setRequestHeader "Connection", "Keep-Alive"
    G_HTTP_Connection_Obj.Send (reqJson)

    MsgBox G_HTTP_Connection_Obj.responseText

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *