Results 1 to 4 of 4

Thread: [RESOLVED] How to get Microsoft Interop in toolbox for use

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    182

    Resolved [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.

    Much appreciate any help you can provide.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,978

    Re: How to get Microsoft Interop in toolbox for use

    It's not a tool, so it won't be in your toolbox.
    In your projects IDE menus, click Project, then Properties, choose References to add a reference...

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,066

    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.
    Attached Images Attached Images  
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    182

    Re: How to get Microsoft Interop in toolbox for use

    Quote Originally Posted by jmcilhinney View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width