0

我编写了一些从我们的服务器检索文本并将该文本写入 Word 文档的代码。

我们正在将我们的办公套件从 2007 年升级到 2013 年,但是在 Word 2013 中测试我以前工作的代码时遇到了问题。

我已将其范围缩小到该http.send行,这似乎没有发送任何内容。当我在 2007 套件上运行代码时,我稍等片刻,然后它跳转到http_OnResponseFinished()Sub,但在 2013 套件中它不会进入那个 sub。

URL 是正确的,并且在 2007 和 2013 套件之间看起来相同/返回相同的数据。

  Public Sub Download(Url As String, Optional Async As Boolean = True)

    Debug.Print "About to download text from url '" & Url & "'."

    http.Open "GET", Url, True 'http must be opened before it can send the request

    http.SetRequestHeader "Content-type", "application/json"

    http.Send 'Sends the request

'    If Wait Then
'        http.WaitForResponse
'    End If
End Sub
Private Sub http_OnResponseFinished()

    Dim Response As String

    Response = http.ResponseText

    WriteTextToWord Response

    Finished = True

    Debug.Print "Completed downloading and inserting text, icons and links."

    If err <> 0 Then
        Call writeToLog(err.Description)
    End If
End Sub
4

1 回答 1

0

我发现了这个问题。

我在代码中进一步使用代理服务器,由于某种原因使 http 对象无法连接到服务器。

通过删除代理我解决了这个问题,因为这个程序的使用只是内部的,我认为不使用代理是好的。

于 2016-08-24T12:40:32.540 回答