none
How to Solve the Error : "Exception from HRESULT: 0x800A03EC"

    Question

  • My Code is

     Excel.Range _nValidationRange = xlApp.get_Range("B2", "B11");

     

    I had this error when i execute the follwing line of code in vs 2008..

     

    _nValidationRange.Validation.Add(Excel.XlDVType.xlValidateList, Excel.XlDVAlertStyle.xlValidAlertStop, Excel.XlFormatConditionOperator.xlBetween, dropDownValues, Type.Missing);

    Thanks a lot to all..

    • Moved by CoolDadTxMVP Monday, July 12, 2010 10:05 AM Not IDE related (From:Visual C# IDE)
    • Moved by SamAgain Tuesday, July 13, 2010 8:09 AM better fit (From:.NET Base Class Library)
    Tuesday, July 06, 2010 1:01 PM

Answers

  • Hi, Chari

    The Com exception with HRESULT code 0x800A03EC could be caused by many reasons.

    The most probably reason in Validation.Add method could be that you add the validation multiple times. You could only add a validation one time, if you add this validation multiple times, the exception may be thrown.

    See the following code which check this.

                Range range = (Range)objSheet.get_Range("A6", "A6");

                Validation validationVal = range.Validation;

                try

                {

                    //int type = validationVal.Type; is used to check whether the validation is added, if not added, it will throw an COM

                    //Exception when you get its type.

                    int type = validationVal.Type;

                    Console.WriteLine("The validation have already been added.");

                }

                catch (System.Runtime.InteropServices.COMException)

                {

                    //The validation have not been added.

                    range.Validation.Add(Microsoft.Office.Interop.Excel.XlDVType.xlValidateList, Microsoft.Office.Interop.Excel.XlDVAlertStyle.xlValidAlertStop, Microsoft.Office.Interop.Excel.XlFormatConditionOperator.xlBetween, 99, Missing.Value);     

                }

    Thanks

    Chao

     

    • Proposed as answer by Chao Kuo Tuesday, July 13, 2010 8:11 AM
    • Marked as answer by Bessie Zhao Wednesday, July 14, 2010 1:52 AM
    Sunday, July 11, 2010 2:54 PM

All replies

  • Hi, Chari

    The Com exception with HRESULT code 0x800A03EC could be caused by many reasons.

    The most probably reason in Validation.Add method could be that you add the validation multiple times. You could only add a validation one time, if you add this validation multiple times, the exception may be thrown.

    See the following code which check this.

                Range range = (Range)objSheet.get_Range("A6", "A6");

                Validation validationVal = range.Validation;

                try

                {

                    //int type = validationVal.Type; is used to check whether the validation is added, if not added, it will throw an COM

                    //Exception when you get its type.

                    int type = validationVal.Type;

                    Console.WriteLine("The validation have already been added.");

                }

                catch (System.Runtime.InteropServices.COMException)

                {

                    //The validation have not been added.

                    range.Validation.Add(Microsoft.Office.Interop.Excel.XlDVType.xlValidateList, Microsoft.Office.Interop.Excel.XlDVAlertStyle.xlValidAlertStop, Microsoft.Office.Interop.Excel.XlFormatConditionOperator.xlBetween, 99, Missing.Value);     

                }

    Thanks

    Chao

     

    • Proposed as answer by Chao Kuo Tuesday, July 13, 2010 8:11 AM
    • Marked as answer by Bessie Zhao Wednesday, July 14, 2010 1:52 AM
    Sunday, July 11, 2010 2:54 PM
  • Hello Chari,

    I am writing to check the status of the issue on your side. Could you please let me know if the suggestion works for you or not? If you have any questions or concerns, please feel free to let me know. I will be more than happy to be of assistance.

    Best regards,
    Bessie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Wednesday, July 14, 2010 1:52 AM