Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE Download under Excel 2003

Status
Not open for further replies.

Cotton9

MIS
Feb 3, 2002
57
0
0
US
Attempting to download a S & P stock market graph. This snipped works under Excel 2007 but fails under 2003. I have tried many variations from this web site and others with no closer solution.


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&quoteBox=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
    '   [b]12029[/b]   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




D. Buckman
US Army Corps of Engineers, Omaha

Learn from the past, Live in the present, Create the future
 
>'oResp = oXML.responseBody

Is this line supposed to be commented out?
 
The line oResp = oXML.responseBody should not be commented out.

Thanks,

D. Buckman
US Army Corps of Engineers, Omaha

Learn from the past, Live in the present, Create the future
 
It appears to be something with the S & P url as the code works with a test url to a local server.
I can past the S & P url into IE and display the target graph so it Excel that doesn't like it. Is there a character limit on oXML.Open "GET" command?

D. Buckman
US Army Corps of Engineers, Omaha

Learn from the past, Live in the present, Create the future
 
>Is there a character limit on oXML.Open "GET" command?

Not in theory. The HTTP spec doesn't mention one. However, there may well be a practical one.

This talks about a 2083-character limit on URL's in IE.

An unforeseen consequence of the information revolution has been the exponential propagation of human error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top