Import picture into Excel cell

G

Gandalf the White

I am trying to import a picture off of the web, not data, into an Excel
cell.
When I do a New Web Query, while the table visually includes the image, the
image is not downloaded.
I think that is because the image is stored at a different URL.
When I enter the URL of the image into the cell, all I get is the URL
address.
If I double click on the cell, IE shows me the image.
So, I know the address is correct.

How do I tell Excel that I want it to download the image?

All assistance gratefully appreciated.
Gandalf
 
J

Joel

I usually right click the picture and trhen save to a local drive. Then
import the picture into excel using menu option Insert - Picture - From file.
I think if you want to emiminate a step you can use menu Insert - Picture -
Frimn file and put the url address into the picture address. The Picture
isn't sored at the URL of the webpage put in a folder associated with the URL
address.
 
G

Gandalf the White

Thanks Joel, but that is not my goal.

I also do not want to have the image double clicked into an IE window. Why
Excel has to make it this so difficult is beyond me. Unless, of course, I'm
missing something very simple which is very possible. I have been reading
some internet info about this.

It looks like this will require Excel's VB, to accomplish. In the Design
Mode, there is a Control involving Microsoft Web Browser, a Name Box with
WebBrowser1, and a function with =EMBED("Shell.Explorer.2",""). Excel's
Microsoft Visual Basic containing:

Private Sub Worksheet_Activate()
WebBrowser1.Navigate "www.worldcommunitygrid.org/images/pb/faah_0.jpg"
End Sub

This all I have been able to uncover across many web pages, so far, but it
will not work for me. Surprise, surprise. I am not into VB. I'm sure
someone out there in Internet land is rofl. I feel I am a tweak away from
making this work, but what that tweak is I have no idea. You see, I have
been doing my homework, so to speak. It's just that, in the web info, I
think I am assumed to know something I don't.

NOTE: I've discovered all this since I initially posted this thread. Since
this is all within the Excel program application, I have not address this to
the VB newsgroup. If I should, please let me know.

All assistance gratefully appreciated.
Gandalf
 
J

Joel

I hate excel also because it makes it so difficult to do some obvious simple
taskw. I'vew been doing a lot of programming in excel VBA using the internet
explorer. I put a sample of my code below. I don't know if there is a way
with the internet explorer to copy a picture and place it on the worksheet.
I still think the way is to use the Insert Picture.

You can use this line to import a picture fro a file

ActiveSheet.Pictures.Insert( _
set MyPicture = "C:\Documents and Settings\Joel\" & _
"My Documents\MyPictures\lincoln.bmp")

Here is a JPG file I added to my worksheet from microsoft.com using the same
command

Sub AddPicture()

MyPicture = "ftp://ftp.microsoft.com/Products/Windows/" & _
"Windowsce/007LOGO.JPG"

Set MyPict = ActiveSheet.Pictures.Insert(MyPicture)

End Sub

Here is an example of using internet explorer from Excel VBA

Sub GetZipCodes()


ZIPCODE = InputBox("Enter 5 digit zipcode : ")

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

URL = "http://zip4.usps.com/zip4/citytown_zip.jsp"

'get web page
IE.Navigate2 URL
Do While IE.readyState <> 4
DoEvents
Loop

Do While IE.busy = True
DoEvents
Loop
Set Form = IE.document.getElementsByTagname("Form")

Set zip5 = IE.document.getElementById("zip5")
zip5.Value = ZIPCODE


Set ZipCodebutton = Form(0).onsubmit

Form(0).submit
Do While IE.busy = True
DoEvents
Loop

Set Table = IE.document.getElementsByTagname("Table")
Location = Table(0).Rows(2).innertext
IE.Quit
MsgBox ("Zip code = " & ZIPCODE & " City/State = " & Location)


End Sub
 
G

Gandalf the White

Joel, again thanks for the reply, but again I'm not into VB.
Your code is like Greek to me.
Multiple lines of Greek is still Greek. :)

The code from my post seems to create a small IE window inside the cell.
It's just not bringing in the image.
Can someone show me how to make "my" code work?

All assistance gratefully appreciated.
Gandalf
 
J

Joel

what you are doing is wrong

Private Sub Worksheet_Activate()
WebBrowser1.Navigate "www.worldcommunitygrid.org/images/pb/faah_0.jpg"
End Sub


1) The worksheet Activate will load the picture everytime you change the
worksheet. You only need to load the picture once.

2) You don't need to use a web browser function. Just inserting the picture
will work. Here is the code I think you should use

Sub GetPicture()

PictureURL = "http://www.worldcommunitygrid.org/images/pb/faah_0.jpg"

Set MyPict = ActiveSheet.Pictures.Insert(PictureURL)

End Sub

I tested this code and it work just like it should.
 
G

Gandalf the White

Sorry for the double post. My ignorance.

This is what I needed. Great.
Thanks Joel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top