Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Have Excel Get png picture from webpage?

8 views
Skip to first unread message

shockley

unread,
Mar 30, 2003, 9:54:33 PM3/30/03
to
I think I'm out of my depth but I'll ask anyway:
 
I would like to have Excel download the chart on this webpage:
 
I try opening the page as a workbook but the chart doesn't appear.  Not sure why this is, but suspect it is some fancy web technology getting in the way.  Ultimate goal is to automate and download thousands of these pics every day <g>.
 
Sub GetChart()
    URL = "http://finance.yahoo.com/q?s=MSFT&d=c&k=c1&a=v&p=s&t=5d&l=off&z=l&q=b"
    Workbooks.Open URL
    Set wbkURL = ActiveWorkbook    'In case you want to explore the Locals Window
End Sub
 
Appreciate any help!
 
Larry

Trevor Shuttleworth

unread,
Mar 31, 2003, 2:33:52 PM3/31/03
to
Larry
 
try Tools | Options | Objects and select Show All.  Works for me in Excel 2000.  It is a picture rather than a Chart.  Is that what you are expecting ?
 
Regards
 
Trevor
 

shockley

unread,
Mar 31, 2003, 7:17:34 PM3/31/03
to
Trevor, thanks for testing that operation on your system and very good to
know it works for somebody. I'm using xl97 and have tried it with same
result whether in win98 or win2K. Maybe I will have to upgrade...

>try Tools | Options | Objects and select Show All. <

This is how my program is set up.

>It is a picture rather than a Chart. Is that what you are expecting ?<

Yes, it's a picture (of a chart) that I'm after. Would you mind checking
which cell the picture is in on your worksheet? You may have to select all
cells and Edit | Clear | Formats. I doubt this will tell me anything, but I
just want to be sure I'm not missing it by some kinda trick...

Thanks again,
Larry

"Trevor Shuttleworth" <Tre...@shucks.demon.co.uk> wrote in message
news:uf92st79...@TK2MSFTNGP11.phx.gbl...

shockley

unread,
Mar 31, 2003, 8:38:34 PM3/31/03
to
Update: I tried the procedure on a different chart site (BigCharts) and got
this message:

"The interactive charting feature of BigCharts requires the use of frames.
Your browser does not appear to support frames. You will be limited to the
QuickChart interface. If you upgrade to a more recent browser you will be
able to use this feature."

So, apparently, xl97 is using an old version of IE...

Larry


"Trevor Shuttleworth" <Tre...@shucks.demon.co.uk> wrote in message
news:uf92st79...@TK2MSFTNGP11.phx.gbl...

Tim Williams

unread,
Apr 1, 2003, 12:21:18 AM4/1/03
to
XL will use whatever version of IE you have installed - it probably is
having a problem with the fames though, since it's not clear which frame you
would want to load. Try finding the url of the frame you're after and using
that instead.

here's a non-excel method to get pics from the web:

Sub tester()
FindImages
"http://finance.yahoo.com/q?s=MSFT&d=c&k=c1&a=v&p=s&t=5d&l=off&z=l&q=b"
End Sub

Sub FindImages(sURL As String)

Dim oDoc As New MSHTML.HTMLDocument

Dim IE As New InternetExplorer
Dim i As Integer
IE.navigate sURL

Do While IE.ReadyState <> READYSTATE_COMPLETE
Loop

Set oDoc = IE.Document

For i = 1 To oDoc.images.Length
If oDoc.images(i - 1).src Like "http://ichart.yahoo.com/*" Then
saveImg oDoc.images(i - 1).src, ThisWorkbook.Path & "\temp.png"
End If
Next i

Set oDoc = Nothing
Set IE = Nothing

End Sub

Sub saveImg(sURL As String, sPath As String)
Dim oXHTTP As New MSXML2.XMLHTTP
Dim oStream As New ADODB.Stream
Dim oFSO As New Scripting.FileSystemObject

oXHTTP.Open "GET", sURL, False
oXHTTP.send

oStream.Type = adTypeBinary
oStream.Open
oStream.Write oXHTTP.responseBody
oStream.SaveToFile sPath, adSaveCreateOverWrite
oStream.Close

Set oXHTTP = Nothing
Set oStream = Nothing
Set oFSO = Nothing

End Sub

You'll need to add references to msxml, ado and IE. Will work for
non-framed sites, but could possibly be modified for framed sites also.


Tim.

"shockley" <shoc...@frontiernet.net> wrote in message

news:u46ia.63$lx1...@news02.roc.ny.frontiernet.net...

shockley

unread,
Apr 1, 2003, 12:29:47 PM4/1/03
to
Tim, wow!  This is a very nice program and runs perfectly when I put it in
my symbol file loop.  My karma must be in very good shape....  Thankyou!

Needless to say, the web technology in your code is well beyond my grasp, so
I would have been flailing away without it. I'll be studying your code
and your other suggestions for some time...
 
Also, I took the URL for the actual picture from the source code so as to eliminate the middle procedure, so now there is only one web access per symbol and it runs twice as fast—I'm getting 2 downloads per second (dsl), which lets me get 7000 symbols in about an hour!! (assuming the server doesn't cut me off).

Best, most grateful regards,
Larry



"Tim Williams" <saxifrax@pacbell*dot*net> wrote in message
news:#v9sH6A#CHA....@TK2MSFTNGP11.phx.gbl...
0 new messages