Created
August 5, 2017 19:08
-
-
Save kashcode/bdc5627ab51032889c90350235d69e23 to your computer and use it in GitHub Desktop.
Excel - images get from URL, resize rows by image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.extendoffice.com/documents/excel/4212-excel-insert-image-from-url.html