Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ERROR : Exception from HRESULT: 0x800A03EC

ERROR : Exception from HRESULT: 0x800A03EC

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netcomsysadminhelp
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    varshavmane
    wrote on last edited by
    #1

    Hello All, I am using ASP.NET 2005(C#). I want to show and save the excel file on server. For this I opened excel file in iframe and kept a save button outside the iframe. On Page Load I have the following code:

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    try
    {
    string fileName = AppDomain.CurrentDomain.BaseDirectory + "SaveExcelFile\\Excel1.xls";
    Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
    Microsoft.Office.Interop.Excel.Workbook ObjWB;
    Microsoft.Office.Interop.Excel.Worksheet ObjWS;
    Object missing = System.Reflection.Missing.Value;
    if (ObjExcel == null)
    {
    //'throw an exception
    throw (new Exception("Unable to Start Microsoft Excel"));
    }
    else
    {
    ObjExcel.Visible = true;
    ObjExcel.DisplayAlerts = false;
    ObjWB = ObjExcel.Workbooks._Open(fileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
    ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)ObjWB.ActiveSheet;
    Session["ExcelObject"] = ObjExcel;
    Session["WorkBook"] = ObjWB;
    Session["WorkSheet"] = ObjWS;
    htxtFileName.Value = "SaveExcelFile/Excel1.xls";
    }
    }
    catch (Exception ex)
    {
    Response.Write("Page Load Error : " + ex.Message);
    }
    }
    }

    and On Save Button Click event I have the following code:

    protected void btnSaveFileToServer_Click(object sender, EventArgs e)
    {
    try
    {
    if (Session["ExcelObject"] != null && Session["WorkBook"] != null && Session["WorkSheet"] != null)
    {
    Microsoft.Office.Interop.Excel.Application ObjExcel = (Microsoft.Office.Interop.Excel.Application)Session["ExcelObject"];
    Microsoft.Office.Interop.Excel.Workbook ObjWB = (Microsoft.Office.Interop.Excel.Workbook)Session["WorkBook"];
    Microsoft.Office.Interop.Excel.Worksheet ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)Session["WorkSheet"];
    ObjExcel.ThisWorkbook.Save();

    P P 3 Replies Last reply
    0
    • V varshavmane

      Hello All, I am using ASP.NET 2005(C#). I want to show and save the excel file on server. For this I opened excel file in iframe and kept a save button outside the iframe. On Page Load I have the following code:

      protected void Page_Load(object sender, EventArgs e)
      {
      if (!IsPostBack)
      {
      try
      {
      string fileName = AppDomain.CurrentDomain.BaseDirectory + "SaveExcelFile\\Excel1.xls";
      Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
      Microsoft.Office.Interop.Excel.Workbook ObjWB;
      Microsoft.Office.Interop.Excel.Worksheet ObjWS;
      Object missing = System.Reflection.Missing.Value;
      if (ObjExcel == null)
      {
      //'throw an exception
      throw (new Exception("Unable to Start Microsoft Excel"));
      }
      else
      {
      ObjExcel.Visible = true;
      ObjExcel.DisplayAlerts = false;
      ObjWB = ObjExcel.Workbooks._Open(fileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
      ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)ObjWB.ActiveSheet;
      Session["ExcelObject"] = ObjExcel;
      Session["WorkBook"] = ObjWB;
      Session["WorkSheet"] = ObjWS;
      htxtFileName.Value = "SaveExcelFile/Excel1.xls";
      }
      }
      catch (Exception ex)
      {
      Response.Write("Page Load Error : " + ex.Message);
      }
      }
      }

      and On Save Button Click event I have the following code:

      protected void btnSaveFileToServer_Click(object sender, EventArgs e)
      {
      try
      {
      if (Session["ExcelObject"] != null && Session["WorkBook"] != null && Session["WorkSheet"] != null)
      {
      Microsoft.Office.Interop.Excel.Application ObjExcel = (Microsoft.Office.Interop.Excel.Application)Session["ExcelObject"];
      Microsoft.Office.Interop.Excel.Workbook ObjWB = (Microsoft.Office.Interop.Excel.Workbook)Session["WorkBook"];
      Microsoft.Office.Interop.Excel.Worksheet ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)Session["WorkSheet"];
      ObjExcel.ThisWorkbook.Save();

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      Have you tried googling with the error message as the search string. You might find what it means.

      "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

      V 1 Reply Last reply
      0
      • P Paul Conrad

        Have you tried googling with the error message as the search string. You might find what it means.

        "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

        V Offline
        V Offline
        varshavmane
        wrote on last edited by
        #3

        Thanks Paul for replying. Yes I have tried but didnt get much help :( I am not able to figure out what is the exact problem in the code. Please help me...

        P 1 Reply Last reply
        0
        • V varshavmane

          Thanks Paul for replying. Yes I have tried but didnt get much help :( I am not able to figure out what is the exact problem in the code. Please help me...

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          I've seen this kind of thing happen when there is an instance of Excel, ( or Word, doesn't really matter when using Office Interop ) that is not closed, and a New is invoked the second time through. I'd put a check in your code to make sure you are creating a single instance of Excel, and closing that instance when done with it.

          "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

          1 Reply Last reply
          0
          • V varshavmane

            Hello All, I am using ASP.NET 2005(C#). I want to show and save the excel file on server. For this I opened excel file in iframe and kept a save button outside the iframe. On Page Load I have the following code:

            protected void Page_Load(object sender, EventArgs e)
            {
            if (!IsPostBack)
            {
            try
            {
            string fileName = AppDomain.CurrentDomain.BaseDirectory + "SaveExcelFile\\Excel1.xls";
            Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel.Workbook ObjWB;
            Microsoft.Office.Interop.Excel.Worksheet ObjWS;
            Object missing = System.Reflection.Missing.Value;
            if (ObjExcel == null)
            {
            //'throw an exception
            throw (new Exception("Unable to Start Microsoft Excel"));
            }
            else
            {
            ObjExcel.Visible = true;
            ObjExcel.DisplayAlerts = false;
            ObjWB = ObjExcel.Workbooks._Open(fileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
            ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)ObjWB.ActiveSheet;
            Session["ExcelObject"] = ObjExcel;
            Session["WorkBook"] = ObjWB;
            Session["WorkSheet"] = ObjWS;
            htxtFileName.Value = "SaveExcelFile/Excel1.xls";
            }
            }
            catch (Exception ex)
            {
            Response.Write("Page Load Error : " + ex.Message);
            }
            }
            }

            and On Save Button Click event I have the following code:

            protected void btnSaveFileToServer_Click(object sender, EventArgs e)
            {
            try
            {
            if (Session["ExcelObject"] != null && Session["WorkBook"] != null && Session["WorkSheet"] != null)
            {
            Microsoft.Office.Interop.Excel.Application ObjExcel = (Microsoft.Office.Interop.Excel.Application)Session["ExcelObject"];
            Microsoft.Office.Interop.Excel.Workbook ObjWB = (Microsoft.Office.Interop.Excel.Workbook)Session["WorkBook"];
            Microsoft.Office.Interop.Excel.Worksheet ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)Session["WorkSheet"];
            ObjExcel.ThisWorkbook.Save();

            P Offline
            P Offline
            Paul Conrad
            wrote on last edited by
            #5

            In btnSaveFileToServer_Click....

            ASP.NET 2.0 wrote:

            Microsoft.Office.Interop.Excel.Worksheet ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)Session["WorkSheet"]; ObjExcel.ThisWorkbook.Save();

            Add something like ObjExcel.Quit, so you can dispose of the Excel app when done with it.

            "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

            V 1 Reply Last reply
            0
            • P Paul Conrad

              In btnSaveFileToServer_Click....

              ASP.NET 2.0 wrote:

              Microsoft.Office.Interop.Excel.Worksheet ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)Session["WorkSheet"]; ObjExcel.ThisWorkbook.Save();

              Add something like ObjExcel.Quit, so you can dispose of the Excel app when done with it.

              "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

              V Offline
              V Offline
              varshavmane
              wrote on last edited by
              #6

              thanks for the reply Paul, but its not working. now the error is coming on page load it self and excel file is not getting saved :( Please help me... Thanks again.

              P 1 Reply Last reply
              0
              • V varshavmane

                thanks for the reply Paul, but its not working. now the error is coming on page load it self and excel file is not getting saved :( Please help me... Thanks again.

                P Offline
                P Offline
                Paul Conrad
                wrote on last edited by
                #7

                Well, it's late here. I'm curious as to why this is a problem. I'll write my own little mock up of your code you are trying to do and see what is up. Stay tuned :)

                "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                V 1 Reply Last reply
                0
                • P Paul Conrad

                  Well, it's late here. I'm curious as to why this is a problem. I'll write my own little mock up of your code you are trying to do and see what is up. Stay tuned :)

                  "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                  V Offline
                  V Offline
                  varshavmane
                  wrote on last edited by
                  #8

                  hey thanks Paul. I am trying this from yesterday but :( First I was getting Error "Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005." I solved that but now getting this error. Thanks again.

                  O 1 Reply Last reply
                  0
                  • V varshavmane

                    hey thanks Paul. I am trying this from yesterday but :( First I was getting Error "Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005." I solved that but now getting this error. Thanks again.

                    O Offline
                    O Offline
                    OleHansen
                    wrote on last edited by
                    #9

                    Hi, found a possible solution here: http://www.made4dotnet.com/Default.aspx?tabid=141&aid=15

                    1 Reply Last reply
                    0
                    • V varshavmane

                      Hello All, I am using ASP.NET 2005(C#). I want to show and save the excel file on server. For this I opened excel file in iframe and kept a save button outside the iframe. On Page Load I have the following code:

                      protected void Page_Load(object sender, EventArgs e)
                      {
                      if (!IsPostBack)
                      {
                      try
                      {
                      string fileName = AppDomain.CurrentDomain.BaseDirectory + "SaveExcelFile\\Excel1.xls";
                      Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
                      Microsoft.Office.Interop.Excel.Workbook ObjWB;
                      Microsoft.Office.Interop.Excel.Worksheet ObjWS;
                      Object missing = System.Reflection.Missing.Value;
                      if (ObjExcel == null)
                      {
                      //'throw an exception
                      throw (new Exception("Unable to Start Microsoft Excel"));
                      }
                      else
                      {
                      ObjExcel.Visible = true;
                      ObjExcel.DisplayAlerts = false;
                      ObjWB = ObjExcel.Workbooks._Open(fileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
                      ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)ObjWB.ActiveSheet;
                      Session["ExcelObject"] = ObjExcel;
                      Session["WorkBook"] = ObjWB;
                      Session["WorkSheet"] = ObjWS;
                      htxtFileName.Value = "SaveExcelFile/Excel1.xls";
                      }
                      }
                      catch (Exception ex)
                      {
                      Response.Write("Page Load Error : " + ex.Message);
                      }
                      }
                      }

                      and On Save Button Click event I have the following code:

                      protected void btnSaveFileToServer_Click(object sender, EventArgs e)
                      {
                      try
                      {
                      if (Session["ExcelObject"] != null && Session["WorkBook"] != null && Session["WorkSheet"] != null)
                      {
                      Microsoft.Office.Interop.Excel.Application ObjExcel = (Microsoft.Office.Interop.Excel.Application)Session["ExcelObject"];
                      Microsoft.Office.Interop.Excel.Workbook ObjWB = (Microsoft.Office.Interop.Excel.Workbook)Session["WorkBook"];
                      Microsoft.Office.Interop.Excel.Worksheet ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)Session["WorkSheet"];
                      ObjExcel.ThisWorkbook.Save();

                      P Offline
                      P Offline
                      priya_velan
                      wrote on last edited by
                      #10

                      Hi, I tried your code, I get the error even in my local dev machine. The error when executing the line "ObjExcel.ThisWorkbook.Save();" is : "Exception from HRESULT: 0x800A03EC". If you find the solution for the above, pls help me out to solve. Thanks Priya

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups