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

  • Home
  • SEARCH
  • 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 692135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:37:10+00:00 2026-05-14T02:37:10+00:00

I have the following interface defined to expose a .NET class to COM: [InterfaceType(ComInterfaceType.InterfaceIsDual)]

  • 0

I have the following interface defined to expose a .NET class to COM:

[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("6A983BCC-5C83-4b30-8400-690763939659")]
[ComVisible(true)]
public interface IComClass
{
    object Value { get; set; }

    object GetValue();

    void SetValue(object value);
}

The implementation of this interface is trivial:

[ClassInterface(ClassInterfaceType.None)]
[Guid("66D0490F-718A-4722-8425-606A6C999B82")]
[ComVisible(true)]
public class ComClass : IComClass
{
    private object _value = 123.456;

    public object Value
    {
        get
        {
            return this._value;
        }

        set
        {
            this._value = value;
        }
    }

    public object GetValue()
    {
        return this._value;
    }

    public void SetValue(object value)
    {
        this._value = value;
    }
}

I have then registered this using RegAsm, and tried to call it from Excel via the following code:

Public Sub ComInterop()

    Dim cc As ComClass
    Set cc = New ComClass

    cc.SetValue (555.555)

    valueByGetter = cc.GetValue 
    valueByProperty = cc.Value 

    cc.Value = 555.555 

End Sub

When I step throught this code, valueByGetter = 555.5555 and valueByProperty = 555.555 as expected. However, I get an “Object required” runtime error on the final line.

Why does setting the value via the setter method work but setting via the property fail? What do I have to change to get the property to work as expected?

Edit: I’ve had some useful responses, so my additional question is “will this issue arise with COM clients written in other languages, or is it specific to VBA?”.

  • 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-14T02:37:10+00:00Added an answer on May 14, 2026 at 2:37 am

    Your interface is exported to the type library like this:

    dispinterface IComClass {
        properties:
        methods:
            [id(00000000), propget]
            VARIANT Value();
            [id(00000000), propputref]             // <=== problem here
            void Value([in] VARIANT rhs);
            [id(0x60020002)]
            VARIANT GetValue();
            [id(0x60020003)]
            void SetValue([in] VARIANT Value);
    };
    

    The trouble is the Value property setter, it is declared as propputref instead of propput. That there’s a difference at all is a nasty consistency issue in COM, brought about by it supporting a default property. That’s why you have to use the Set keyword in VBA. Problem is: you’re not passing an object in the VBA code, even though .NET expects one.

    After researching this a bit, I found no ready solution for this problem. There’s a small chance that the Let keyword might work in VBA, I didn’t try it. The only halfway decent fix is to force late binding, instead of ComInterfaceType.InterfaceIsDual use ComInterfaceType.InterfaceIsIDispatch. Or avoid using “object”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.