I used this code from another VBA question thread but I received an error. I am trying to extract the image from the URL without changing the size of the image.It worked for some of the images but then errored out.
I changed it to be Range("D2", Cells (Rows.Count, "D") .End (xlUP) ) and that still did not remove the errorI used this code from another VBA question thread but I received an error. I am trying to extract the image from the URL without changing the size of the image.It worked for some of the images but then errored out.
Yes. Is there a way to tell it to skip that one if it errors out like that?The RowHeight Property ranges from 0 to 409 points so you are probably getting that error because the Picture size (Height) exceeds 409 points.
Skip it with an IF clause something along these lines :Yes. Is there a way to tell it to skip that one if it errors out like that?
If .Height * 0.75 <= 408 Then
URL.EntireRow.RowHeight = .Height
End If
.Height is now Invalid or unqualified reference.Please, place your code inside Code Tags </> so anyone wanting to help can copy it for testing.
You are getting the error because you still have the following line before End With
URL.EntireRow.RowHeight = .Height
Remove that line and the error should not happen.
Sub InsImg()
Dim URL As Range
For Each URL In Range("D2", Cells(Rows.Count, "D").End(xlUp))
With URL.Parent.Pictures.Insert(URL.Value)
.Left = URL.Offset(0, 1).Left
.Top = URL.Offset(0, 1).Top
End With
If .Height * 0.75 <= 408 Then
URL.EntireRow.RowHeight = .Height
End If
Next
End Sub
Sub InsImg()
Dim URL As Range
For Each URL In Range("D2", Cells(Rows.Count, "D").End(xlUp))
With URL.Parent.Pictures.Insert(URL.Value)
.Left = URL.Offset(0, 1).Left
.Top = URL.Offset(0, 1).Top
If .Height * 0.75 <= 408 Then
URL.EntireRow.RowHeight = .Height
End If
End With
Next
End Sub
Removing the * 0.75 solved it. Thank you!VBA Code:Sub InsImg() Dim URL As Range For Each URL In Range("D2", Cells(Rows.Count, "D").End(xlUp)) With URL.Parent.Pictures.Insert(URL.Value) .Left = URL.Offset(0, 1).Left .Top = URL.Offset(0, 1).Top If .Height * 0.75 <= 408 Then URL.EntireRow.RowHeight = .Height End If End With Next End Sub
Also, try the smae code but without the * 0.75 and see what happens