WinHttpRequest使用用户自己的ActiveDirectory凭据

时间:2018-02-14 15:19:18

标签: excel vba credentials winhttprequest

我正在使用以下代码来获取要在Excel工作表中显示的图像(SharePoint网站上保存的部分)。我想使用用户自己的Active Directory凭据来访问该URL。我到目前为止的代码是:

Dim Request As Object
Dim ResponseStatus As Variant
Dim ImgURL As String
ImgURL = "https://someValidURL/" & ExtraPartNo & ".jpg"

    Set Request = CreateObject("WinHttp.WinHttpRequest.5.1")

    With Request
        .Open "GET", ImgURL, True
        .Send
        .WaitForResponse
        ResponseStatus = .StatusText
    End With
    Set Request = Nothing

    If ResponseStatus = "OK" Then
        ImgURL = "https://someValidURL/" & ExrtaPartNo & ".jpg"
    Else
        SetterImgURL = "https://someValidURL/AwaitingImage.jpg"
    End If

想法是显示零件的图像(如果它存在但如果没有则显示AwaitingImage.jpg

0 个答案:

没有答案