VBA XMLHTTP禁用身份验证弹出窗口

问题描述 投票:0回答:1

关于此问题VBA XMLHTTP clear authentication?,我也试图通过VBA中的基本身份验证。它运行完美。

我唯一关心的是登录弹出窗口,每当在请求中发送错误的用户名或密码时,都会弹出登录窗口。有没有一种方法可以禁用此功能,并从VBA本身向用户发送消息框,告知用户身份验证失败?

更新

VBA代码:

Dim objHTTP As New MSXML2.XMLHTTP60

With objHTTP

    .Open "GET", UrlUserService, False
    .setRequestHeader "Content-Type", "application/json"
    .setRequestHeader "Accept", "application/json"
    .setRequestHeader "Cache-Control", "no-cache"
    .setRequestHeader "Authorization", "Basic " + Base64Encode(userName + ":" + userPwd)
    .setRequestHeader "Pragma", "no-cache"
    .setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
    .send ""
    response = .Status

End With

弹出enter image description here

vba excel-vba authentication excel
1个回答
0
投票

使用Msxml2.XMLHTTP.6.0协议并将凭据作为请求的一部分传递

。打开“ GET”,pUrl,false,“ pUsername”,“ pPassword”

© www.soinside.com 2019 - 2024. All rights reserved.