0
votes

I have written some code that retrieves text from our server and writes that text into a word document.

We are in the process of upgrading our office suite from 2007 to 2013, but I'm having issues when testing my previously working code in Word 2013.

I've narrowed it down to the http.send line, this doesn't seem to send anything. When I run the code on 2007 suite I get a small wait and then it jumps to the http_OnResponseFinished() Sub, but in 2013 suite it doesn't enter that sub.

The URL is the correct one and it looks the same/returns the same data between 2007 and 2013 suites.

  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
1
Are you using Set http = CreateObject("WinHttp.WinHttpRequest.5.1") ?Cody G

1 Answers

0
votes

I found the issue.

I was using a proxy server further up in the code that for some reason made the http object unable to connect to servers.

By removing the proxy I fixed the issue and since the use of this program is only internal I think that not using a proxy will be okey.