PDA

View Full Version : VBA code not working in 365



mickyflash
12-03-2019, 06:08 AM
I have recently upgraded to Excel 365 from 2010 which I have used with no problem for many years.

I have this code which still works perfectly fine in 2010, but I am getting a 400 error message when I try and run the spreadsheet in 365

Is there an obvious reason why 365 does not like the code?


Public Sub Add_Images_To_Cells()
ActiveSheet.Pictures.DELETE

Dim lastRow As Long
Dim URLs As Range, URL As Range

With ActiveSheet
lastRow = .Cells(Rows.Count, "A").End(xlUp).Row
Set URLs = .Range("A2")
End With

For Each URL In URLs
URL.Offset(0, 4).Select
URL.Parent.Pictures.Insert URL.Value
DoEvents
Next
End Sub

Bob Phillips
12-03-2019, 06:29 AM
Can you post an example workbook, it is hard to see anything without context.

mickyflash
12-03-2019, 06:46 AM
here is a very small element of the spreadsheet that shows the code working/not working

Paul_Hossler
12-03-2019, 07:25 AM
You might have to download the pictures first, and then Insert them locally from the HD

mickyflash
12-03-2019, 07:42 AM
You might have to download the pictures first, and then Insert them locally from the HD

Ahh I was trying to avoid that, I might just go back to 2010 then, as it works OK there

Paul_Hossler
12-03-2019, 07:50 AM
Some one else may have a better idea, but when I pasted the URL.Value into Edge, it just wanted to download the picture