Sep 03 2022 01:21 AM
Sep 03 2022 01:21 AM
I downloaded a file which include a column of image URL. I want to convert these URL into actual images for that I have Written a VB code but I don't know why it is throwing me following error : Run time error 1004 Unable to get the Insert property of pictures class
My Excel file looks like:
while My VB Code is
Public Sub Add_Images_To_Cells() Dim lastRow As Long Dim URLs As Range, URL As Range Dim pic As Picture Dim urlColumn As String With ActiveSheet urlColumn = "F" lastRow = .Cells(Rows.Count, urlColumn).End(xlUp).Row Set URLs = .Range(urlColumn & "3:" & urlColumn & lastRow) End With For Each URL In URLs If InStr(URL.Value, "http") > 0 Then URL.Offset(0, 0).Select Set pic = URL.Parent.Pictures.Insert(URL.Value) With pic.ShapeRange .LockAspectRatio = msoFalse .Height = URL.Offset(0, 0).Height - 1 .Width = URL.Offset(0, 0).Width - 1 .LockAspectRatio = msoTrue End With URL.Clear DoEvents End If Next
On Debugging the debugger is highlighting this line Set pic =URL.Parent.Pictures.Insert(URL.Value)
Can anyone help how I display images instead of URL either in the same column or other column?
Sep 03 2022 04:50 AM
It is not a microsoft site, without warranty
Sep 03 2022 06:26 AM - edited Sep 03 2022 06:28 AM
@NikolinoDE It didn't work for me. I am downloading my Excel File from Salesforce and I have made changes in column ranges accordingly but didn't work. I am not sure whether it is because of Spreadsheet format I am downloading from salesforce or anything else. I am attaching my File here
Could you please help me with it.
Sep 03 2022 11:22 AM
The file cannot be opened and if I open it anyway, it is empty.
If you cannot insert the file, then send the file as a private message.
I don't know your digital environment, so I can't make any statements as to why it's not working for you.
Here is another VBA code, maybe it works for you.
At least if not, it will "Debug" and show you the error line.
At the same time, if I may recommend, additional information about Excel version, operating system and storage medium would be beneficial for all participants, most of all for you.
Thank you for your understanding and patience