Friday 25 November 2016

Convert URL to Image Excel | URL to IMAGE

This can be achieved in Excel using the Macros.
Macros are very easy to install and use:
  1. ALT-F11 brings up the VBE window
  2. ALT-I ALT-M opens a fresh module
  3. Paste the stuff in and close the VBE window
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Sub InsImg()

    Dim URL As Range
        
    For Each URL In Range("F2", Cells(Rows.Count, "F").End(xlUp))
        With URL.Parent.Pictures.Insert(URL.Value)
            .Left = URL.Offset(0, 1).Left
            .Top = URL.Offset(0, 1).Top
            URL.EntireRow.RowHeight = .Height
        End With
    Next

End Sub

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
In above code F2 is name of the cell in which URL is present.

When you will start conversion it will continuously go and hit the Google , if the URL's in large amount then it will through an error after few minutes.

If you save the workbook, the macro will be saved with it. If you are using a version of Excel later then 2003, you must save the file as .xlsm rather than .xlsx
enter image description here
To remove the macro:
  1. bring up the VBE window as above
  2. clear the code out
  3. close the VBE window
To use the macro from Excel:
  1. ALT-F8
  2. Select the macro
  3. Touch RUN
To learn more about macros in general, see:
and
Macros must be enabled for this to work!


1 comment:

  1. Wow. This is really cool! Finally found a solution that I'm not confused with.

    Could you show how would it look like for:
    - LINKING instead of PASTING (the Excel file not having the physical image inside but only displaying an image from the URL/folder)
    - setting a maximum height and maximum width (so that I know the image will not extend on the right and if the image is to big, it will be scaled down)

    Thanks. Greg

    ReplyDelete