Skip to content

Instantly share code, notes, and snippets.

@pejantantangguh
Created September 3, 2018 05:40
Show Gist options
  • Save pejantantangguh/d396a9cdbbf8d5b94b2e4e9157543198 to your computer and use it in GitHub Desktop.
Save pejantantangguh/d396a9cdbbf8d5b94b2e4e9157543198 to your computer and use it in GitHub Desktop.
URL Path on Excel and grabbing images
Sub URLPictureInsert()
Dim Pshp As Shape
Dim xRg As Range
Dim xCol As Long
On Error Resume Next
Application.ScreenUpdating = False
'Need to update the active range sheets,
Set Rng = ActiveSheet.Range("H2:H94")
For Each cell In Rng
Filename = cell
ActiveSheet.Pictures.Insert(Filename).Select
Set Pshp = Selection.ShapeRange.Item(1)
If Pshp Is Nothing Then GoTo lab
xCol = cell.Column + 1
Set xRg = Cells(cell.Row, xCol)
With Pshp
.LockAspectRatio = msoFalse
.Width = 100
.Height = 100
.Top = xRg.Top + (xRg.Height - .Height) / 2
.Left = xRg.Left + (xRg.Width - .Width) / 2
End With
lab:
Set Pshp = Nothing
Range("A2").Select
Next
Application.ScreenUpdating = True
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment