JohnDoe1976
New Member
- Joined
- Nov 17, 2020
- Messages
- 2
- Office Version
- 365
- 2019
- 2016
- 2013
- 2011
- 2010
- 2007
- Platform
- Windows
Hi all, I've trailed a LOT of posts trying to find the answer, and I've seen similar issues but not this one.
Essentially I'm trying to insert this image (+others) into my workbook:
but I'm getting this:
code is below:
Sub URLPictureInsert()
Dim Pshp As Shape
Dim xRg As Range
Dim xCol As Long
'On Error Resume Next (commented out for now)
Application.ScreenUpdating = False
LR = Sheets("Range Vis").Range("E65536").End(xlUp).Row
Set Rng = Sheets("Range Vis").Range("E3:E" & LR)
For Each cell In Rng
filenam = cell
ActiveSheet.Pictures.Insert(filenam).Select
Set Pshp = Selection.ShapeRange.Item(1)
If Pshp Is Nothing Then GoTo lab
xCol = cell.Column + 13
Set xRg = Cells(cell.Row, xCol)
With Pshp
.LockAspectRatio = msoFalse
If .Width > xRg.Width Then .Width = xRg.Width * 2 / 3
If .Height > xRg.Height Then .Height = xRg.Height * 2 / 3
.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
Can anyone help please?
Essentially I'm trying to insert this image (+others) into my workbook:
but I'm getting this:
code is below:
Sub URLPictureInsert()
Dim Pshp As Shape
Dim xRg As Range
Dim xCol As Long
'On Error Resume Next (commented out for now)
Application.ScreenUpdating = False
LR = Sheets("Range Vis").Range("E65536").End(xlUp).Row
Set Rng = Sheets("Range Vis").Range("E3:E" & LR)
For Each cell In Rng
filenam = cell
ActiveSheet.Pictures.Insert(filenam).Select
Set Pshp = Selection.ShapeRange.Item(1)
If Pshp Is Nothing Then GoTo lab
xCol = cell.Column + 13
Set xRg = Cells(cell.Row, xCol)
With Pshp
.LockAspectRatio = msoFalse
If .Width > xRg.Width Then .Width = xRg.Width * 2 / 3
If .Height > xRg.Height Then .Height = xRg.Height * 2 / 3
.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
Can anyone help please?