[RESOLVED] How to get Microsoft Interop in toolbox for use
I'm trying to generate a VB interface with Excel, but the compiler does not recognize Imports Excel = Microsoft.Office.Interop.Excel and declares that Excel.Application does not exist.
Through some suggestions, from another post, I understood that the toolbox should have the Excel interop and I just needed to check it to include it in the project. No Excel, or office, shows up in the com library in the toolbox.
Is the toolbox where I want to do what I'm trying or is there another place that I would get the Excel Interop included in my project.
Re: How to get Microsoft Interop in toolbox for use
The Toolbox lists specific controls and components that can be added to a form in the designer. As .paul. says, what you're talking about is not that. What you're looking for is a COM library that contains types that you can then access in code. When you build your project, it generates an assembly, which is a .NET EXE or DLL. Those assemblies contain the types declared in your code and, if it's a DLL, that library can be referenced in other projects in order for them to use the types it contains. .NET projects can reference .NET assemblies and they can also reference COM libraries. What you're talking about is the latter. Office uses libraries built using COM technology and Interop libraries exist to enable .NET applications to interoperate with those COM libraries. Your .NET code interacts with the .NET code in the Interop library and it has low-level code to interact with the COM library. You can generate Interop libraries but Microsoft provides standard Interop libraries for Office applications, known as Primary Interop Assemblies (PIAs), because that's a very common thing for people to want to do.
For a .NET Framework project, you can select Add Reference from the Project menu or right-click the project in the Solution Explorer and select Add -> Reference, then select the COM section. For .NET Core projects, where .NET assemblies are referenced via NuGet packages, you can select Add COM reference or Add -> COM Reference. I suggest that you then search for "excel" in the dialogue and it should provide you just the Excel PIA(s) on your system.
Re: How to get Microsoft Interop in toolbox for use
Originally Posted by jmcilhinney
The Toolbox lists specific controls and components that can be added to a form in the designer. As .paul. says, what you're talking about is not that. What you're looking for is a COM library that contains types that you can then access in code. When you build your project, it generates an assembly, which is a .NET EXE or DLL. Those assemblies contain the types declared in your code and, if it's a DLL, that library can be referenced in other projects in order for them to use the types it contains. .NET projects can reference .NET assemblies and they can also reference COM libraries. What you're talking about is the latter. Office uses libraries built using COM technology and Interop libraries exist to enable .NET applications to interoperate with those COM libraries. Your .NET code interacts with the .NET code in the Interop library and it has low-level code to interact with the COM library. You can generate Interop libraries but Microsoft provides standard Interop libraries for Office applications, known as Primary Interop Assemblies (PIAs), because that's a very common thing for people to want to do.
For a .NET Framework project, you can select Add Reference from the Project menu or right-click the project in the Solution Explorer and select Add -> Reference, then select the COM section. For .NET Core projects, where .NET assemblies are referenced via NuGet packages, you can select Add COM reference or Add -> COM Reference. I suggest that you then search for "excel" in the dialogue and it should provide you just the Excel PIA(s) on your system.
Thaks you so much..... This is exactly what I was looking for.