none
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 8000401a

    Question

  • In SharePoint Document Library Event , we are creating object of Microsoft.Office.Interop.Word.DLL, but getting below error

    Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 8000401a

    Environment: Windows 2003, SP1, MOSS 2007 SP1, SQL Server 2005 and Office 2007 is installed in the Server, DLL version is 12

     

     

     

     

     

     


    Marulasiddappa SB (Swamy)
    Wednesday, February 02, 2011 3:58 AM

Answers

  • This issue is resolved by doing below changes

    1. Go to the Start-Run menu to type in "dcomcnfg"  and hit enter to load "Component Services" MMC.
    2. Select the "Microsoft Excel Application" item through "Component Services" MMC->Component Services->Computers->My Computer->DCOM Config->Microsoft Excel Application
    3. Right click and select Properties->Select Identity Tab->Select This user and add the Administrator accout and password
    4. Select Security Tab, Under "Launch and Activation Permissions", Choose "Customize", Click "Edit" button, Add the everyone account and add all the Permissions.
    5. Do the same thing in "Access Permissions" and "Configuration Permissions"

     


    Marulasiddappa SB (Swamy)
    • Marked as answer by eryang Monday, February 14, 2011 5:55 AM
    Tuesday, February 08, 2011 11:49 AM
  • An important reminder:

    Office COM automation in a server environment is fully-*un*-supported. 

    Please read the following document on reasons why and alternatives:

    http://support.microsoft.com/kb/257757

    Also note that is you decide to run office on the server, you'll need to ensure your licenses are in order. You might need a Office licenses for every user that might cause the office automation to run, which can be very costly if your application is available through the internet or to 3rd parties.

    Next to the Microsoft provided alternatives, there are a number of 3rd party components that allow office automation tasks and usually stay pretty close to the Word API to make conversion of your code relatively easy. I've worked with Aspose components for this purpose in the past and can recommend them (http://www.aspose.com/categories/.net-components/aspose.words-for-.net/default.aspx).

    • Proposed as answer by Jesse Houwing Thursday, February 10, 2011 5:43 PM
    • Marked as answer by eryang Monday, February 14, 2011 5:55 AM
    Thursday, February 10, 2011 5:43 PM

All replies

  • Check COMException Error:8000401a

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Wednesday, February 02, 2011 4:14 AM
  • After adding applicaation pool account as Identity in DCOMCNFG, now we are able to create Application class object,

    But , not able to create Document class object, getting error

    Retrieving the COM class factory for component with CLSID {00020906-0000-0000-C000-000000000046} failed due to the following error: 80080005.


    Marulasiddappa SB (Swamy)
    Thursday, February 03, 2011 7:11 AM
  • Tested by creating simple web application in the same environment, working wothout any issues.

    We are not able to create Application and Document class objects in SharePoint Event.

    Environment

    Environment: Windows 2003, SP1, MOSS 2007 SP1, SQL Server 2005 and Office 2007 is installed in the Server, DLL version is 12


    Marulasiddappa SB (Swamy)
    Friday, February 04, 2011 4:23 AM
  •  

    You may try SharePoint forum for further support of your question.

     

    Please feel free to let us know if you have any concern.


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, February 08, 2011 4:17 AM
  • Hi eryang, I don't think this issue is related to SharePoint. The exception is from Word's COM server.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Tuesday, February 08, 2011 5:05 AM
  • This issue is resolved by doing below changes

    1. Go to the Start-Run menu to type in "dcomcnfg"  and hit enter to load "Component Services" MMC.
    2. Select the "Microsoft Excel Application" item through "Component Services" MMC->Component Services->Computers->My Computer->DCOM Config->Microsoft Excel Application
    3. Right click and select Properties->Select Identity Tab->Select This user and add the Administrator accout and password
    4. Select Security Tab, Under "Launch and Activation Permissions", Choose "Customize", Click "Edit" button, Add the everyone account and add all the Permissions.
    5. Do the same thing in "Access Permissions" and "Configuration Permissions"

     


    Marulasiddappa SB (Swamy)
    • Marked as answer by eryang Monday, February 14, 2011 5:55 AM
    Tuesday, February 08, 2011 11:49 AM
  • An important reminder:

    Office COM automation in a server environment is fully-*un*-supported. 

    Please read the following document on reasons why and alternatives:

    http://support.microsoft.com/kb/257757

    Also note that is you decide to run office on the server, you'll need to ensure your licenses are in order. You might need a Office licenses for every user that might cause the office automation to run, which can be very costly if your application is available through the internet or to 3rd parties.

    Next to the Microsoft provided alternatives, there are a number of 3rd party components that allow office automation tasks and usually stay pretty close to the Word API to make conversion of your code relatively easy. I've worked with Aspose components for this purpose in the past and can recommend them (http://www.aspose.com/categories/.net-components/aspose.words-for-.net/default.aspx).

    • Proposed as answer by Jesse Houwing Thursday, February 10, 2011 5:43 PM
    • Marked as answer by eryang Monday, February 14, 2011 5:55 AM
    Thursday, February 10, 2011 5:43 PM
  • I had the same issue in Webservice which create Excel file using Interop

    Creating Excel application and Object working properly in my local Machine but getting this error after deploying the service in server IIS.Made all changes in 'dcomcnfg' but no use. My basic idea behind using Excel objects is Format file. I acheived it without using Excel objects now using XML fomat.(As bleow)

    //Creating Excel file
    
          excelDoc = new System.IO.StreamWriter(fileName, false);
    
          //XML formating of the data
          const string startExcelXML = "<xml version>\r\n<Workbook " +
              "xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\r\n" +
              " xmlns:o=\"urn:schemas-microsoft-com:office:office\"\r\n " +
              "xmlns:x=\"urn:schemas-  microsoft-com:office:" +
              "excel\"\r\n xmlns:ss=\"urn:schemas-microsoft-com:" +
              "office:spreadsheet\">\r\n <Styles>\r\n " +
              "<Style ss:ID=\"Default\" ss:Name=\"Normal\">\r\n " +
              "<Alignment ss:Vertical=\"Bottom\"/>\r\n <Borders/>" +
              "\r\n <Font/>\r\n <Interior/>\r\n <NumberFormat/>" +
              "\r\n <Protection/>\r\n </Style>\r\n " +
              "<Style ss:ID=\"BoldColumn\">\r\n <Font " +
              "x:Family=\"Swiss\" ss:Bold=\"1\"/>\r\n </Style>\r\n " +
              "<Style ss:ID=\"Color\">\r\n <Font " +
              "x:Family=\"Swiss\" ss:Color=\"#65909A\"/>\r\n </Style>\r\n " +
              "<Style ss:ID=\"StringLiteral\">\r\n <NumberFormat" +
              " ss:Format=\"@\"/>\r\n </Style>\r\n <Style " +
              "ss:ID=\"Decimal\">\r\n <NumberFormat " +
              "ss:Format=\"0.00\"/>\r\n </Style>\r\n <Style " +
              "ss:ID=\"Currency\">\r\n <NumberFormat " +
              "ss:Format=\"$#,##,##0.00\"/>\r\n </Style>\r\n <Style " +
              "ss:ID=\"Percentage\">\r\n <NumberFormat " +
              "ss:Format=\"#,##,##0.#0%\"/>\r\n </Style>\r\n <Style " +
              "ss:ID=\"Percentageless\">\r\n <NumberFormat " +
              "ss:Format=\"0.##%\"/>\r\n </Style>\r\n " +
              "<Style ss:ID=\"Integer\">\r\n <NumberFormat " +
              "ss:Format=\"#,##,##0\"/>\r\n </Style>\r\n <Style " +
              "ss:ID=\"DateLiteral\">\r\n <NumberFormat " +
              "ss:Format=\"mm/dd/yyyy;@\"/>\r\n </Style>\r\n " +
              "</Styles>\r\n ";
          const string endExcelXML = "</Workbook>";
          
          int rowCount = 0;
          int sheetCount = 1;
    
          excelDoc.Write(startExcelXML);
          excelDoc.Write("<Worksheet ss:Name=\"Export" + "-" + Geography + "\">");
          excelDoc.Write("<Table>");
    
    
          ///Write parametersTitle
          excelDoc.Write("<Row>");
          //excelDoc.Write("<Cell ss:StyleID=\"BoldColumn\"><Data ss:Type=\"String\">");
          excelDoc.Write("<Cell ss:StyleID=\"Color\"><Data ss:Type=\"String\">");
          excelDoc.Write("Optimization parameters");
          excelDoc.Write("</Data></Cell>");
          //excelDoc.Write("</Data></Cell>");
          excelDoc.Write("</Row>");
    
          ///Write parametercolumnname
          excelDoc.Write("<Row>");
          ///Perform operations to format your data and write that in exceldoc
    excelDoc.Write("</Row>");
          excelDoc.Write("</Table>");
          excelDoc.Write(" </Worksheet>");
    ///If want to insert further data in Next sheet of .xls
    excelDoc.Write("<Worksheet ss:Name=\"Export" + sheetCount + "\">");
              excelDoc.Write("<Table>");
    ///Operations to write the data
    
          excelDoc.Write("</Table>");
          excelDoc.Write(" </Worksheet>");
          excelDoc.Write(endExcelXML);
          excelDoc.Close();
    

     Hope this helps buddies who have similar issues with creating Excel file.

     

     

    Friday, February 11, 2011 7:06 AM
  • Have a look at Excel Package plus (http://epplus.codeplex.com) its a free and open source library which can be used to read and write excel files without the need of having Excel installed on the server (which is a bad idea in every case).

    Aspose.Cells is also a very nice alternative, albeit being a commercial one.

    Friday, February 11, 2011 8:36 AM