Skip to content

Instantly share code, notes, and snippets.

@kashcode
Created August 5, 2017 19:08
Show Gist options
  • Save kashcode/bdc5627ab51032889c90350235d69e23 to your computer and use it in GitHub Desktop.
Save kashcode/bdc5627ab51032889c90350235d69e23 to your computer and use it in GitHub Desktop.
Excel - images get from URL, resize rows by image
Sub URLPictureInsert()
'Updateby Extendoffice 20161116
Dim Pshp As Shape
On Error Resume Next
Application.ScreenUpdating = False
Set Rng = ActiveSheet.Range("E2:E640")
For Each cell In Rng
filenam = cell
ActiveSheet.Pictures.Insert(filenam).Select
Set Pshp = Selection.ShapeRange.Item(1)
With Pshp
.LockAspectRatio = msoTrue
.Width = 158
.Cut
End With
Cells(cell.Row, cell.Column + 1).PasteSpecial
Next
Application.ScreenUpdating = True
End Sub
Sub ResizePictureRow()
Dim shpPic As Shape
On Error Resume Next
Set shpPic = ActiveSheet.Shapes(Selection.Name)
On Error GoTo 0
If Not shpPic Is Nothing Then
If shpPic.Type = msoPicture Then
ActiveSheet.Rows(shpPic.TopLeftCell.Row).RowHeight = shpPic.Height
End If
End If
End Sub
Sub ResizeAllPictureRow()
Dim Sh As Shape
With ActiveSheet
For Each Sh In .Shapes
If Not Application.Intersect(Sh.TopLeftCell, .Range("F84:F640")) Is Nothing Then
If Sh.Type = msoPicture Then ActiveSheet.Rows(Sh.TopLeftCell.Row).RowHeight = Sh.Height
End If
Next Sh
End With
End Sub
@kashcode
Copy link
Author

kashcode commented Aug 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment