Image URLs to actual images using Excel VBA

The following program converts Image URLs to actual images using Excel VBA. It does not need to get the information using IE or Httpserver requests.

 

Sub URLPictureInsert()
    Dim shp As Shape
    Dim Rge As Range
    Dim Col As Long
    On Error Resume Next
    Application.ScreenUpdating = False
    Set Rng = ActiveSheet.Range("a1:a100")
    For Each cell In Rng
        filename = cell
        ActiveSheet.Pictures.Insert(filename).Select
        Set shp = Selection.ShapeRange.Item(1)
        If shp Is Nothing Then GoTo skip
        Col = cell.Column + 1
        Set Rge = Cells(cell.Row, Col)
        With shp
            .LockAspectRatio = msoFalse
            .Width = 150
            .Height = 150
            .Top = Rge.Top + (Rge.Height - .Height) / 2
            .Left = Rge.Left + (Rge.Width - .Width) / 2
        End With
skip:
    Set shp = Nothing
    Range("A1").Select
    Next
    Application.ScreenUpdating = True
End Sub
 
https://www.extendoffice.com/documents/excel/4212-excel-insert-image-from-url.html

You must be logged in to post a comment.