+ Reply to Thread
Results 1 to 3 of 3

Inserting a corrupt Image (JPEG) Causes Excel to Crash. How to avoid?

  1. #1
    Registered User
    Join Date
    08-30-2012
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    83

    Inserting a corrupt Image (JPEG) Causes Excel to Crash. How to avoid?

    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:
    Please Login or Register  to view this content.
    to insert the images into the worksheet.
    (Full line is
    Please Login or Register  to view this content.
    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.

    I have tried
    Please Login or Register  to view this content.
    but it is still causing the program to crash.

    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.
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,882

    Re: Inserting a corrupt Image (JPEG) Causes Excel to Crash. How to avoid?

    Try function like below?
    Reference: https://msdn.microsoft.com/en-us/lib...(v=vs.60).aspx

    Please Login or Register  to view this content.
    I tested by renaming extension of .txt file to .jpg.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    08-30-2012
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    83

    Re: Inserting a corrupt Image (JPEG) Causes Excel to Crash. How to avoid?

    CK76 - That was exactly what I was looking for - THANK YOU!

    (I can confirm that this has the desired / required effect!)

    J

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Corrupt files> workbooks.open> excel crash
    By ayush002 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-27-2016, 03:00 PM
  2. Vlookup JPEG Image to Excel
    By zulkarnin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-09-2014, 06:03 AM
  3. Import JPEG image to cell in Excel 2010
    By COgreywolf in forum Excel General
    Replies: 3
    Last Post: 12-10-2013, 05:48 PM
  4. VBA: Put text from excel to jpeg image by matching image name.
    By sroysroy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2013, 01:47 AM
  5. JPEG image data into excel sheet
    By sharmanjali87 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-30-2010, 05:24 AM
  6. Need Help creating a Excel File from Jpeg Image
    By Ericb410 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-30-2009, 06:10 AM
  7. Importing an Image (jpeg) in Excel
    By Hubert Rétif in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-08-2005, 11:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1