Background
My office has used Office 2010 for quite some time, and I have written an application to generate some Excel files that we upload to a web site. Recently, our company decided to go with Office 365. So, on my development machine I had 2010 and 365 (whatever version that is), as well as Visual Studio 2017.
My company is assuredly going to require that all non-365 versions of office be removed, so today, I uninstalled 2010 to see what breaks.
The Issue
I fixed the references in the project to point to the correct objects now. I have a reference to Microsoft Excel 16.0 Object Library, and I ended up having to modify statements like
Dim ExApp AS Excel.Application= new Excel.Application
to
Dim ExApp AS Microsoft.Office.Interop.Excel.Application= new Microsoft.Office.Interop.Excel.Application
and now the code compiles with no errors. However, when I run it, I get the following error on the above statement:
System.Runtime.InteropServices.COMException: '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)).'
I am not sure why.
Internet searches on that error are typically really old, and most describe trying to run the application on a machine where Office is not installed. I can't run it on my development machine in debug mode.
Related
I am trying to build a VB.NET Windows Forms application in VS 2022 using an ActiveX DLL named CP4DLL that I built many years ago in VB6.
I have included a reference to the DLL in the project and the code recognises the objects, methods and properties from the DLL but when I run the VB.NET code it generates the following message:
"System.Runtime.InteropServices.COMException: 'Creating an instance of
the COM component with CLSID {59CA4977-912A-47C6-BAB7-D1B26C0D6ACC}
from the IClassFactory failed due to the following error: 800a0beb
0x800A0BEB.'"
I have a VB6 .EXE application which uses that DLL and when I install it on my computer it and it runs fine.
What else do I need to add to the VB.NET project to solve this problem ?
I just installed Visual Studio 2012 Ultimate and I am trying to create a managed code extension project for Excel 2010 (32 bit Office Professional Plus). I have tried using the .NET 4.0 template contained in VS Ultimate for an Excel 2010 workbook. When I create the project everything looks fine until I run it.
Excel opens and I get the error message "The customization assembly could not be found or could not be loaded. You can still edit and save the document. Contact your administrator or the author of this document for further assistance." The details section is blank.
I have tried everything I could think of to figure this out and I have run out of ideas. I removed all addins from Excel except for the VSTO Design-Time Adaptor for Excel. I removed all personal macros. I set every directory I could think of to "trusted" in Excel and lowered the security settings for all options to "enabled (not recommended)". I completely uninstalled Visual Studio and re-installed. There are no errors or warnings showing up in Visual Studio. I also checked to make sure ".NET Programmability Support" was installed for my copy of Microsoft Excel.
I would link my code but I haven't written anything. I can't even get the default template to load when I run the project. A few others at work have the same setup as me and VSTO runs fine for them using the same steps. I even had someone send me a working project but it gives me the same message when I try to run it.
Is there anything else I can check to see where the problem is occurring? I tried setting break points in the project but it is failing before it gets to any of them.
Thanks so much for your help.
I've run into the same problem with Visual Studio 2010.
I isolated the problem to an SSRS reporting link we were trying to run from the add-in. I removed all the reporting stuff (service reference, sub-dirs, etc.) - the add-in runs fine.
We just ran into this and discovered that a method had a system exception that was not handled. It was hard to track down but once the culprit method had an exception handler the customization finished loading properly.
An amateur programmer has made a nice little program that works through VBA on top of a MS-Access2010 database. We are asked to make an installer for this database+VBA project. The code runs fine on any computer with Office installed, but on computers without Office we get the error above. On computers without office we install the MS-Access2010 Runtime, which is free, in order to be able to open the .accde file at all. But this does not prevent the VBA error.
I did some research on the issue but did not find anything related to this specific scenario. How can this be troubleshooted?
The problem was a version mismatch between the .accde file (sp1) and the installed ms access 2010 runtime (original) After upgrading the runtime to sp1 all was fine.
For the visual folks:
And at line 61:
Everything I'm finding on the web is one of 3 solutions for the problem:
The user is trying to use an interop assembly without Excel installed. I have M$ office pro 2010 installed. So that's not the issue.
I'm not typing it out but you can look here
Users are running the interop assembly in 64-bit, I'm on a 32 bit machine. So that's unrelated. But I did try compiling as 32bit only instead of Any CPU. Didn't help.
Basically fix #2 is for those running this code on a server and their code is executing under the ASP user account, in my case its a desktop app so this should be unrelated but in desperation I added "Everyone" to the permissions and gave them all privileges. Didn't work.
So now I'm turning to here. Any questions, comments, concerns?
I know that there are millions of posts about this already but I cant seem to find one that mirrors my issue.
I am using VS2010 and want to automate excel and I'm trying to work through the example here.
MS Tutorial
The problem is when I go to add the reference as mentioned
3.Add a reference to the Microsoft Excel Object Library. To do this, follow these steps: •On the Project menu, click Add Reference.
•On the COM tab, locate Microsoft Excel Object Library, and click Select.
There is no such reference available.
Could someone please let me know if this is the right way to automate excel with VS2010.
If it is could someone please let me know why I dont have the COM option for excel.
Im wanting to write in VB.net but if someone has an example in C# that would be fine.
Kind Regards
Ash
I have tried implementing automation using the Microsoft.Office.Interop.Excel.Application dll but i get the following exception when I try to create the excel application.
This line generates the error.
EXL = New Microsoft.Office.Interop.Excel.Application()
This is the exception
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))
If you have Office 2010 installed on your machine but still don't see it in the COM tab then there are reasonable odds that you have the 64-bit version of Office installed. Visual Studio is a 32-bit program, it cannot see the registry entries for 64-bit COM servers.
Workarounds are to use the primary interop assembly, it ought to be installed on your machine. Use the .NET tab and select Microsoft.Office.Interop.Excel. Next option is to import the type library directly. Use the Browse tab and navigate to c:\program files\microsoft office\office14 and select excel.exe. Set the Copy Local property of the added references to True to avoid having to deploy the PIA to the target machine.
Also be sure that your app can run as a 64-bit process. In vb.net that's selected with Project + Properties, Compile tab, scroll down, Advanced Compile Options, set Target CPU to "AnyCPU".