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

  • SEARCH
  • Home
  • 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 255119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:54:14+00:00 2026-05-11T21:54:14+00:00

Does anyone know if a site (even non-Microsoft), that has details on COMExceptions/HRESULTS. When

  • 0

Does anyone know if a site (even non-Microsoft), that has details on COMExceptions/HRESULTS.

When I attempted to Save my Excel Workbook after using the Copy() function, I received this error:

ERROR - Unable to SaveWorkbook()
System.Runtime.InteropServices.COMException (0x800A03EC): Document not saved.

P.S. I’m doing this in a tight loop for 10K+ files, but reading the files worked out fine, but saving them is proving to be not fun.

Also, if anyone has had the issue of Excel hemorrhaging memory when you use the Copy() function let me know.

Thanks!

P.S.S If anyone needs further clarification please let me know

Edit 1

Here’s what’s going on. I’ve been asked to update some XLS files (10K+ in fact), by copying the Active Sheet to a new Sheet (same Workbook) and update the original Sheet by performing some conversion. The problem comes when I save the Workbook.

Here is some excerpts from my application:

///.... UpdateSpreadsheet() Routine
Microsoft.Office.Interop.Excel.Workbook wb = null;

try
{
    wb = ef.GetWorkbook(fileName, false, true);
}
catch (Exception ex)
{
    logger.Error(ex.ToString());
}

Microsoft.Office.Interop.Excel.Worksheet ws = null;

try
{
    ws = wb.Sheets[Foo.WorksheetName] as Microsoft.Office.Interop.Excel.Worksheet;
}
catch (Exception ex)
{
    logger.Error(ex.ToString());
}

bool result = false;

if (ws != null)
    result = ef.CopyWorksheet(ws, Foo.WorksheetName);

if (result)
{
   //... update the sheet as appropriate
}

try
{
    ef.SaveWorkbook(wb, fileName);  //eventually this line crashes, it's random, but so far after the 500th file, and I get that COM Exception.
    //.. update Foo object to reflect copied worksheet
}
catch (Exception ex)
{
    //something happened, we can't save, so close and destroy the workbook
    logger.Error("Unable to SaveWorkbook()", ex);   
}
finally
{
    ef.DestoryWorkbook(wb, fileName);
    ef.DestroyWorksheet(ws);
}

//// CopyWorksheet() Method
public bool CopyWorksheet(Worksheet ws, String sourceSheet)
{
    try
    {
        try
        {
            Worksheet sheet = GetWorksheet(sourceSheet + " (2)");

                    //I don't think the below is necessary, but I'm paranoid about memory leaks
            ExcelTools.OfficeUtil.ReleaseRCM(sheet);
            sheet = null;

            return false;
        }
        catch (Exception)
        {
            ws.Copy(Missing.Value, ws); //this line never errors out
        }
        
        return true;
    }
    catch (Exception)
    {
        return false;
    }
    finally
    {
        ws.Activate();
    }
}

/// SaveWorkbook()
public void SaveWorkbook(Workbook wb)
{
    if (wb != null)
    {
        wb.Save();
    }
}
  • 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-05-11T21:54:14+00:00Added an answer on May 11, 2026 at 9:54 pm

    If you break down the HRESULT value, the facility code is FACILITY_CONTROL, and the error code is 1004. From some online searching, it appears that this code is generated for a variety of different errors, some of which seem related to copying worksheets programmatically (see for example this KB article).

    It might help to post more details about what you’re doing, or search online for this HRESULT and see what problems others may have had which look similar to what you’re doing.

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

Sidebar

Related Questions

Does Anyone know of a site that has converted the google maps api store
Does anyone know any site or book that presents problems like python challenge ,
Does anyone know of a site or page, or know the order of execution
Does anyone know why my site is all messed up on safari? I need
Does anyone know exactly what happens when you change your Zend site at, say,
Does anyone know of a debugging utility that can debug some cakephp code line
Does anyone know what's wrong with this code? Cipher cipher = Cipher.getInstance(AES/ECB128/PKCS5Padding, SunJCE); Algorithm:
Does anyone know if a user generated HTML5 Canvas could be attached to a
Does anyone know why the file doesn't format correctly on the line < taskinprogress>
Does anyone know how to generate the following generic method declaration using CodeModel? public

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.