[英]VBA in Excel works fine in Windows 2007 machine, but not Windows 10
[英]VBA ServerXMLHTTP code works in Windows 7 but fails in Windows 10
我在Microsoft Access中使用VBA,將XML發送到服務器以獲取響應字符串。 它在Windows 7中可以正常工作。最近,一些用戶已升級到Windows 10,並且該功能不再起作用(Office 16上的所有用戶)。 特定的錯誤是:-2147012867-無法建立與服務器的連接。
錯誤發生在xsite.send行上
這是代碼:
Dim xsite As ServerXMLHTTP60
Set xsite = New ServerXMLHTTP60
On Error Resume Next
xsite.setTimeouts 0, 60000, 30000, 600000
xsite.Open "POST", pServerURL & func, False
aErr = Array(Err.Number, Err.Description)
On Error GoTo 0
If 0 = aErr(0) Then 'No error creating the link
xsite.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
'Set request header with Base64-encoded username/password
xsite.setRequestHeader "Authorization", "Basic " & EncodeBase64(UserName & ":" & Password)
On Error Resume Next
xsite.send "xmlData=" & URLEncode(xmldata)
aErr = Array(Err.Number, Err.Description)
On Error GoTo 0
Debug.Print aErr(0)
Debug.Print aErr(1)
End If
有任何想法嗎?
我有一個類似的問題。 尚未測試您的代碼,但它看起來與我的代碼相似,它也可在Windows7中使用,但不適用於Windows10。 我發現是Windows10防火牆阻止了它。 如果關閉防火牆,您的計算機可能會工作。 我嘗試了各種方法來使防火牆成為例外,但從未成功。 因此,幾次必須運行我的代碼,我必須關閉防火牆。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.