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 7927907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:34:07+00:00 2026-06-03T19:34:07+00:00

I am trying to access COM exposed methods in VBA. Problem: I am seeing

  • 0

I am trying to access COM exposed methods in VBA.

Problem: I am seeing all default methods (like GetHashCode, GetType and ToString) in VBA but not the ones which are part of the COM interface and specifically written to be COM visible (like getStringValue() below).

Set up Details:

  • Visual Studio 2008
  • Windows 7 x64
  • Office 2007
  • .NET 3.5

Interface ‘IGetMyString.cs’

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace SimpleCOMAssembly
{
    [ComVisible(true), GuidAttribute("4153A1AC-ECE9-4f66-B56C-1DDEB6514D5D")]
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    interface IGetMyString
    {
        [DispId(1)]
        string getStringValue();
    }
}

Implementation ‘GetMyString.cs’

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.ComponentModel;

namespace SimpleCOMAssembly
{
    [ComVisible(true), GuidAttribute("0A3D4D65-CF50-4020-BF13-77001F8AAABE")]
    [ProgId("SimpleCOMAssembly.GetMyString")]
    [ClassInterface(ClassInterfaceType.None)]
    public class GetMyString : IGetMyString
    {
        public GetMyString() { }

        [ComVisible(true), Description("Get my string")]
        public string getStringValue()
        {
            return "hello";
        }
    }
}

In Build properties, I checked ‘Make Assembly COM Visible’ (see below snapshot)

enter image description here

Also asked Visual Studio 2005 to make the ‘Register for COM interop’ (see below snapshot)

enter image description here

And, finally as a post build event, I am running the regasm.exe to register the .DLL and also the .TLB to registry as follows:

%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\regasm /codebase "$(TargetPath)" /tlb:"$(TargetDir)$(TargetName).lib"

In Excel Object Explorer view, I enabled COM server (SimpleCOMAssembly written above), and now in the Object Explorer it does not list down the COM interface method (see below)
enter image description here

Can someone help me know what I am missing which is causing the COM interface methods not show in VBA?

EDIT
Attaching ITypeLib View of the generated TLB
enter image description here

  • 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-06-03T19:34:08+00:00Added an answer on June 3, 2026 at 7:34 pm

    The Excel object browser screenshot clearly shows a problem. Note how the GetHashcode, GetType and ToString methods are visible. Those are methods that are inherited from System.Object. But your snippet explicitly (and correctly) uses [ClassInterface(ClassInterfaceType.None)] so that the class implementation is hidden.

    It isn’t hidden. Not so sure how that happened, an old type library from an earlier attempt could explain it. But your build steps are very suspect, you are helping too much. The “Make assembly types COM visible” option is a pretty crude way to force the build system to expose .NET types. But your code is using the refined upper-right-pinky-up-when-you-drink-tea way to expose types to COM. Which includes the [ComVisible(true)] attribute, what the checkbox does, and the [ClassInterface] attribute, which is what the checkbox doesn’t do.

    So the problem is that you asked the build system to implement two interfaces. Whatever it inherited from the base class, _Object in your case, plus what it inherited from the declaration, IMyGetString in your case. Which is fine and all quite COM compatible, but VBA isn’t a very good COM consumer. It only likes the [Default] interface and that’s _Object in your case. Clearly visible from the screenshot.

    So turn off the “Make assembly COM visible” option.

    And choose between either a postbuild event that calls Regasm or the “Register for COM interop” checkbox. Doing it both ways just doubles the odds that you don’t know why it doesn’t work. You only need the postbuild when you need to register the assembly for the 64-bit version of Office.

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

Sidebar

Related Questions

When I access http://www.my_url.com/index.jsp I get the updated web page, but when I'm trying
So I'm trying to access this api https://www.clarityaccounting.com/api-docs/ using SUDS. Here is the code
I'm trying to access a member structs variables, but I can't seem to get
What I'm trying to attempt is to access methods on a Silverlight control via
When trying to access my site: www.X.com The browser changes the url to: www.X.com/
I've had some users trying to access a site that is registered as subdomain.example.com
I'm trying to access a site via their JSON export. The URL is: http://neotest.dabbledb.com/publish/neotest/f820728c-4451-41f6-b346-8cba54e52c6f/projects.jsonp
I am trying to access all the categories in the first level within a
I'm trying to access a server so I can receive a JSON String. But
I am trying to access COM object from on the fly compiled C# code.

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.