I have an Excel 2010 macro that opens all workbooks in a given folder and moves Sheet1 from the new workbooks into a Master Workbook, which was working but extremely slow. Today I updated it to include Application.ScreenUpdating = False
to cut down on the processing time. There is a logo on Sheet1 and with the screen updating addition the logo is now showing the following error:
"This image cannot currently be displayed."
I have done some research and have not found anything on this specific error. One solution suggested that I change to a blank page during the processing without screen updating, however it did not work. Based on other posts the error occurs frequently if you copy a worksheet, rather than move it, because the image is not part of a cell.
Below is a simplified version of the code I am using that still causes the error:
Sub GetSheets()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Path = "G:\Project Dashboards\Testing Folder\"
Filename = Dir(Path & "*.xls")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, UpdateLinks:=True, ReadOnly:=True
Workbooks(Filename).Activate
Sheets(1).Move after:=ThisWorkbook.Sheets(1)
ActiveSheet.Name = ActiveSheet.Cells(2, 17).Value
Workbooks(Filename).Close False
Filename = Dir()
Loop
ActiveWorkbook.Save
Application.ScreenUpdating = True
End Sub
If you comment out Application.ScreenUpdating = False
the image is moved with the worksheet as desired.
Okay, so I don't know the exact cause (sorry - I have not seen an explanation for this yet) but I do know there is an issue with this in 2010. I know of two possible workarounds:
1) you can try not closing the source workbooks until after you turn on screen updating. This to me feels a little cargo cultish as I don't know the exact mechanism behind why this works. Also, IIRC I don't think it works with images inserted as links.
2) you can try using Range.Copy, which should work with any image
Code Examples:
Code examples are totally untested
Option 1:
option 2: