Hi there,
I have a list of strings which may or may not have images (.jpg) associated with them.
If there is an image, I want it added to the sheet. If there is no image, then nothing need done and the program skips on to the next one.
I am using the code:
to insert the images into the worksheet.![]()
Please Login or Register to view this content.
(Full line is
My problem is that there are a few rogue image files which are causing the program to crash at this point when a rougue image is attempted to be inserted into the worksheet.![]()
Please Login or Register to view this content.
I have tried
but it is still causing the program to crash.![]()
Please Login or Register to view this content.
These images do not open up with any program (they are probably corrupted), but I do not want them to bring down the program! How to avoid this?
I suppose, unsurprisingly, I can not upload one of the image files that is causing Excel to crash. Hopefully suggestions can still be made and I will endeavour to test any offered!
Further info:
The code I have attached is to illustrate the issue and reproduce the crash event.
The actual folder contains tens of thousands of images in it and they are being updated on an ad hoc basis. For this reason, I want to first and foremost protect the program from keeling over, should it come across a rogue image. This is the answer that I am looking for!
Thank you for reading the post. Hope someone out there has a solution!
![]()
Please Login or Register to view this content.
Bookmarks