Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7598279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:22:07+00:00 2026-05-30T22:22:07+00:00

I am trying to understand this weird behaviour in VBA. I have two .NET

  • 0

I am trying to understand this weird behaviour in VBA. I have two .NET classes, which inherit interfaces and exposed to COM. I register for COM interop and in VBA I encounter this weird behaviour where the objects show types from incorrect interface. Well explained in code as below:

C# Class:

namespace ComTest
{
    [ComDefaultInterface(typeof(ITestClass))]
    [ClassInterface(ClassInterfaceType.None)]
    public class TestClass : ITestClass
    {
        public string TestMethod()
        {
            return "Version 2-PROD Version";
        }
    }

    [ComDefaultInterface(typeof(ITestTrade))]
    [ClassInterface(ClassInterfaceType.None)]
    public class TestTrade : ITestTrade
    {
        public string TradeName { get; set; }
        public int QuantityNumber { get; set; }
    }
}

In Excel VBA:

Dim objTestClass As ComTest.TestClass
Set objTestClass = New ComTest.TestClass
Dim str As String
objTestClass. ---> I GET ITestTrade methods in objTestClass

Dim tTestTrade As ComTest.TestTrade
Set tTestTrade = New ComTest.TestTrade
tTestTrade. -----> I GET ITestClass methods in tTestTrade

But, if I remove ‘ComTest’ and simply use the class names, this works fine. i.e,

Dim objTestClass As TestClass
Set objTestClass = New TestClass
Dim str As String
objTestClass. ---> I GET ITestClass types

Dim tTestTrade As TestTrade
Set tTestTrade = New TestTrade
tTestTrade. -----> I GET ITestTrade

Can someone please help me understand this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:22:08+00:00Added an answer on May 30, 2026 at 10:22 pm

    I didn’t find exact reason as to why it happened. But apparently something had gone wrong in my tlb registration and the way in which I had my types exposed to COM. This might help for someone if you had similar issues:

    I was able to stop it by:

    • Having a assembly guid attribute for the assembly. (in the assemblyinfo.cs)
    • Specifically mentioning the GUID attribute for every class and exposes interfaces.
    • And using the below way to expose the .Net classes

      [ComVisible(true)]
      [ComDefaultInterface(typeof(IEvfExternalClient))]
      [ClassInterface(ClassInterfaceType.None)]
      public class EvfExternalClient : IEvfExternalClient
      {
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand this inline assembly code which comes from _hypercall0 here
I have an exam tomorrow and I was trying to understand this doubly linked
I have a network with some weird (as I understand) DNS server which causes
I'm having a weird situation that I'm trying to understand. This piece of code
I'm trying to understand this bit of code: in display.php: <html> ... <body> <table>
I am trying to understand this simple hashlib code in Python that has been
I don't know much about database optimization, but I'm trying to understand this case.
I'm trying to understand why this does not work. (Basic example with no validation
I'm trying to understand how this exactly works (I know what it does, I
I am trying to understand why this design decision was made with the rename()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.