サーバーからテキストを取得し、そのテキストを Word 文書に書き込むコードをいくつか書きました。
オフィス スイートを 2007 から 2013 にアップグレード中ですが、以前は動作していたコードを Word 2013 でテストするときに問題が発生しています。
行に絞り込みましたhttp.send
が、これは何も送信していないようです。2007 スイートでコードを実行すると、少し待機してからhttp_OnResponseFinished()
サブにジャンプしますが、2013 スイートではそのサブに入りません。
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