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
End Sub
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
Sep 03 2022 04:55 AM - edited Sep 03 2022 04:59 AM
@NikolinoDE Thanks for reply. I use the same reference but this is not working in my Scenario.
Sep 03 2022 05:07 AM
Just in case, IMAGE(url, alt_text,...) function appeared in Beta version. Have no idea how much time it takes to see it in production.
Sep 03 2022 05:12 AM
SolutionSep 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.
https://mega.nz/file/Eqx1zZDI#hmrJduhQ77zReZi2fFxRM2aaSwaUGVPLbhQc-FBavcg
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
Sep 04 2022 02:42 AM
Sep 03 2022 05:12 AM
Solution