Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7979747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:51:27+00:00 2026-06-04T09:51:27+00:00

I am writing an application that extracts images from an Excel spreadsheet using COM

  • 0

I am writing an application that extracts images from an Excel spreadsheet using COM interop.

It works perfectly fine if I save the file as an XLS (2003 format) from Excel 2010 however if I save it as an XLSX (2007 to 2010 format) it produces this exception “The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))”

My code is below. The exception is thrown by the line pic.Copy(); which works perfectly fine with an XLS.

    public static BitmapSource[] ImportImages(string FileName)
    {
        //Create the Excel Object
        ExcelObj = new Microsoft.Office.Interop.Excel.Application();

        //Create the Workbooks wrapper
        Workbooks workbooks = ExcelObj.Workbooks;

        //Open the Excel workbook
        Workbook workbook = workbooks.Open(FileName);

        //Reference the worksheets in the Excel file
        Sheets sheets = workbook.Worksheets;

        List<BitmapSource> images = new List<BitmapSource>();

        List<Picture> pics = new List<Picture>();

        //Reference the first sheet in the workbook
        Worksheet sheet = sheets[1];

        for (int i = 1; i < 30; i++)
        {
           pics.Add(sheet.Pictures(i));
        }

        foreach (Picture pic in pics)
        {
            pic.Copy();

            if (Clipboard.ContainsImage())
            {
                images.Add(Clipboard.GetImage());
            }

            Marshal.ReleaseComObject(pic);
        }

        Marshal.ReleaseComObject(sheet);
        Marshal.ReleaseComObject(workbooks);
        Marshal.ReleaseComObject(workbook);
        Marshal.ReleaseComObject(sheets);
        ExcelObj.Quit();
        Marshal.ReleaseComObject(ExcelObj);

        return images.ToArray();
    }

Any ideas why this is happening? I need to be able to support 2003 and 2007/2010 with my project.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:51:29+00:00Added an answer on June 4, 2026 at 9:51 am

    While you are targeting both Excel 2003 and 2007/above, I would suggest using the OpenXml SDK to extract pictures for Excel 2007 and above. First off, this is something where the SDK works much better than interop. I haven’t done it for Excel, but wrote code to do the same thing for PowerPoint. It’s blazing fast because you don’t even launch Excel, instead you are directly working of the XML Excel file. Second, it seems that you are doing this on a server, where it’s highly advisable to avoid Interop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a cataloging application that parses through and extracts information from files
I am writing an application that extracts data from a file and then saves
I am writing an application that allows a user to place images on a
Im writing a application that reads logs from 1-many computers in the network. The
I am writing a C# application that needs to extract data from a ListView
I am writing an application that uses the AVAudioRecorder class. It works great except
I am writing an application that retrieves coordinates from a webservice, then plots them
Im writing an application that supposed to send coordinates in an SMS, but I've
I am writing an application that will allow an android phone and java application
I am writing an application that sends commands to a unix shell. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.