Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
Hello,

I'm trying to use a Visual Basic windows form app to open microsoft office 2013 Excel. When my program tries to get Excel to open I get the following error.

An exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll but was not handled in user code

Additional information: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

When I try to run the code it stops at,
Dim xlApp As New Excel.Application

and the above error statement appears.

The beginning of my code is:
Imports Excel = Microsoft.Office.Interop.Excel


Public Class Form1

    'Objects defined
    Dim xlApp As New Excel.Application
    Dim xlWorkBook As Excel.Workbook
    Dim xlSheet As Excel.Worksheet


What I have tried:

I'm new to VB and am not good at debugging.
Posted
Updated 15-Nov-20 5:03am
Comments
Richard MacCutchan 27-May-17 7:40am    
Do you have Excel installed on your system?
[no name] 27-May-17 7:44am    
Only to make it clear, same question like above from Richard MacCutchan. Excel is installed on the machine you are working with?
Because "No Excel" then also "No Interface"
[no name] 27-May-17 7:58am    
"am not good at debugging", then get good at it. The error message is perfectly clear and remedies are easily found using a simple google search so I am not sure what your actual question would be.

That error means that the version of Excel you wrote this code against is not installed on the machine.
 
Share this answer
 
Comments
Member 13197019 27-May-17 21:32pm    
Thanks for the responses! I apologize for not mentioning earlier that I have office 2013 installed on my computer and I did add the reference to excel 15.0 when I started my project.
Dave Kreskowiak 27-May-17 22:25pm    
I don't know what to tell you. That's exactly what the error means.

Is Office installed in a manner that really does the installation upon first launch of the application shortcuts? This would install some stuff, enough for COM registration data, but the app is not really installed until you launch it from a shortcut.
Thanks Dave---I checked, and confirmed, that I have been launching from a shortcut. This prompted me to do a repair on the install which has solved the issue. Although I'm not sure what exactly was repaired.
Thanks for everyone's responses!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900