Attempting to download a S & P stock market graph. This snippet works under Excel 2007 but fails under 2003. I have tried many variations from this web site and others with no closer solution.
oXML.Send line fails with status code of 2029
Thanks,
D. Buckman
US Army Corps of Engineers, Omaha
Learn from the past, Live in the present, Create the future
oXML.Send line fails with status code of 2029
Code:
Sub dbins()
Dim cText As String
Dim oXML As Object
Dim oResp
Dim vLocalFile as string
Dim cURL As String
Dim lRetImmed As Boolean ' True = Return immediently, False = wait
vLocalFile = "./S_PGraph.png"
cURL = "[URL unfurl="true"]http://app.quotemedia.com/quotetools"[/URL] & _
"/getChart?webmasterId=90699&symbol=^SP500&" & _
"chscale=3m"eBox=true&chln=1A5488&chfill=" & _
"D6E7F2&chfill2=D6E7F2&chtype=AreaChart&chwid=" & _
"390&chhig=250&chpccol=FF4C00&chfrmon=" & _
"false&chton=false&chpcon=true"
' IE status Property Value & Corresponding statusText Value
' 12002 ERROR_INTERNET_TIMEOUT
' 12007 ERROR_INTERNET_NAME_NOT_RESOLVED
' 12029 ERROR_INTERNET_CANNOT_CONNECT
' 12030 ERROR_INTERNET_CONNECTION_ABORTED
' 12031 ERROR_INTERNET_CONNECTION_RESET
' 12152 ERROR_HTTP_INVALID_SERVER_RESPONSE
Set oXML = CreateObject("MSXML2.XMLHTTP")
If oXML Is Nothing Then
MsgBox "For some reason I wasn't able to make a MSXML2.XMLHTTP object"
Exit Sub
End If
oXML.Open "GET", cURL, False
' Send fails and code of 2029
oXML.Send
' Wait for request to finish
Do While oXML.readyState <> 4
DoEvents
Loop
oResp = oXML.responseBody ' Returns the results as a byte array (not very useful)
' Create local file and save results to it
vFF = FreeFile
If Dir(vLocalFile) <> "" Then Kill vLocalFile
Open vLocalFile For Binary As #vFF
Put #vFF, , oResp
Close #vFF
' Clear memory
Set oXML = Nothing
End Sub
Thanks,
D. Buckman
US Army Corps of Engineers, Omaha
Learn from the past, Live in the present, Create the future