0

short disclaimer in order for you to understand how to phrase your answers: I am a total newbie when it comes to programming. All I know are the basic concepts of object oriented programming and VBA, but that's about it. Sometimes VBA is a little annoying though, e.g., when trying to run something in the background. This is what I am trying here.

I am using C# in Visual Studio. When trying to create a new Excel Workbook this exception is thrown:

System.Runtime.InteropServices.COMException: "Retrieving the COM class factory for component with CLSID {00020819-0000-0000-C000-000000000046} failed due to the following error: 80040154

I've done some research and found this thread. The problem is that I don't really understand what I need to do. Maybe someone can help me through rather basic instructions :-D.

Thanks in advance!

All the best, Till

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45

1 Answers1

0

This is a good indicator that something is wrong with your windows registry keys for Office. In that case I'd recommend repairing Excel or Office, so the required windows registry keys can be restored.

Also be aware, Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Thank you for your answer! How would I repair those programs? –  Aug 03 '22 at 10:12
  • Go to the `Control Panel` applet and choose the `Programs` section, in the list you may find the Office installed. By clicking on it and then choosing to repair you can start the process. – Eugene Astafiev Aug 03 '22 at 12:16