Rury Garcia
Rury Garcia

Reputation: 1

Getting an image from an URL in Excel

I have a table in SQL with some fields, and one of this fields is a URL. I need to show all of the info in the table in excel, but I want the URL field to show the image the URL is pointing to instead of the URL itself. How can I show the image at a certain URL in Excel?

Upvotes: 0

Views: 552

Answers (2)

Gready
Gready

Reputation: 1164

Following from JNevill's answer... Andrew Poulsom in 2012 gives a full macro for adding an image from a url in a given cell, to the next cell along... Given the URL is in cell A2 an image will be placed in cell B2:

Sub Test()
    Dim Pic As Picture
    Application.ScreenUpdating = False
    With ActiveSheet.Range("A2")
        Set Pic = .Parent.Pictures.Insert(.Value)
        With .Offset(, 1)
            Pic.Top = .Top
            Pic.Left = .Left
            Pic.Height = .Height
            Pic.Width = .Width
        End With
    End With
    Application.ScreenUpdating = True
End Sub

Upvotes: 1

JNevill
JNevill

Reputation: 50034

This is one of the very few things in VBA that Microsoft has made trivially simple.

If you want to an insert a picture from a URL the code is:

ActiveSheet.Pictures.Insert("http://i.imgur.com/9W8Pb1V.png").Select

That will insert a picture of a bunny with a pancake on it's head into the activesheet in your workbook.

Upvotes: 1

Related Questions