哪些引用从Excel VBA添加HTTP请求

时间:2016-04-11 14:48:49

标签: excel vba excel-vba

我正在使用Excel VBA构建OAuth2.0身份验证工具。

这些是我正在使用的参考资料:

enter image description here

但是,在线编译时代码会中断:

Private objXMLRequest As MSXML2.ServerXMLHTTP

我尝试以管理员身份从命令窗口运行:

regsvr32.exe "c:\windows\system32\winhttp.dll"

regsvr32.exe "c:\windows\system32\winhttpcom.dll"

但他们都返回错误:

RegSvr32 - Entry point DllRegisterServer not found.

2 个答案:

答案 0 :(得分:4)

您必须参考CHARACTER*256 NAME(3,256)

请参阅:https://msdn.microsoft.com/en-us/library/ms763701%28v=vs.85%29.aspx

使用Microsoft XML, v 3.0时,类型必须为Microsoft XML, v 6.0

答案 1 :(得分:2)

使用全功能对其进行测试:

Sub Testa()
 Dim aTests: aTests = Array( _
        "Microsoft.XMLHTTP" _
      , "Msxml2.XMLHTTP" _
      , "Msxml2.XMLHTTP.3.0" _
      , "Msxml2.XMLHTTP.4.0" _
      , "Msxml2.XMLHTTP.5.0" _
      , "Msxml2.XMLHTTP.6.0" _
      , "Microsoft.XMLHTTP.6.0" _
      , "Msxml2.XMLHTTP.7.0" _
 )
 Dim sProgId, sTypeName
 For Each sProgId In aTests
     Dim oX
   On Error Resume Next
     Set oX = CreateObject(sProgId)
     If 0 = Err.Number Then
        sTypeName = TypeName(oX)
     Else
        sTypeName = Err.Description
     End If
   On Error GoTo 0
     MsgBox sProgId + "=>" + sTypeName
 Next

结束子