我正在使用以下代码来获取图像(SharePoint 网站上保存的部分)以显示在 Excel 工作表中。我想使用用户自己的 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