Skip to content

Instantly share code, notes, and snippets.

@tsohr
Created November 12, 2015 11:57
Show Gist options
  • Select an option

  • Save tsohr/76f98f614d5da85ec808 to your computer and use it in GitHub Desktop.

Select an option

Save tsohr/76f98f614d5da85ec808 to your computer and use it in GitHub Desktop.
MS Excel
' http://stackoverflow.com/a/8525125/592817
Sub InsertImage()
Dim urlColumn As Range
Dim imgColumn As Range
Dim fp As String
Set urlColumn = Worksheets(1).UsedRange.Columns("W")
Set imgColumn = Worksheets(1).UsedRange.Columns("X")
Dim i As Long
For i = 2 To urlColumn.Cells.Count
DoEvents
fp = urlColumn.Cells(i).Text
If (Left(fp, 4) = "http") Then
imgColumn.Cells(i).Select
With imgColumn.Worksheet.Shapes.AddPicture(fp, msoTrue, msoTrue, 1, 1, 96, 96)
.Left = imgColumn.Cells(i).Left
.Top = imgColumn.Cells(i).Top
End With
breakLinks
End If
Debug.Print i, urlColumn.Cells.Count, 100# * i / urlColumn.Cells.Count
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment