VBA中自定义COM类中的IntelliSense

Vit*_*ata 9 c# com intellisense vba visual-studio

有没有办法在VBA中自己构建的COM类中获取IntelliSense?

例如,在下面的示例中,每当我按下点(或ctrl + space for shortcut)时,我想显示"Number": 在此输入图像描述

我想,如果以某种方式解决了这个问题,我还会得到一些关于对象公共函数的信息:

在此输入图像描述

那么,有什么建议?

建议1:

在此输入图像描述

dee*_*dee 5

简单的例子看起来像这样。

c#类库命名IntellisenseDemo代码

using System;
using System.Runtime.InteropServices;

namespace IntellisenseDemo
{
    [ComVisible(true)]
    [Guid("41B3F5BC-A52B-4AED-90A0-F48BC8A391F1")]
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    public interface IIntellisenseDemo
    {
        int Number { get; set; }
        string TestString(string name);
    }

    [ComVisible(true)]
    [Guid("20EBC3AF-22C6-47CE-B70C-7EBBA12D0A29")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("IntellisenseDemo.Demo")]
    public class Demo : IIntellisenseDemo
    {
        public int Number { get; set; }
        public string TestString(string name)
        {
            throw new NotImplementedException();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

注意[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]表示一个接口作为调度接口暴露给 COM,它只启用后期绑定。

[ClassInterface(ClassInterfaceType.None)]意味着 CLR 不公开此类型的类接口。COM 客户端可以使用IIntellisenseDemo接口中的方法调用此类的成员。

再高潮

C:\Windows\Microsoft.NET\Framework\v4.0.30319>regasm C:\Temp\IntellisenseDemo.dll /tlb: C:\Temp\IntellisenseDemo.tlb
Run Code Online (Sandbox Code Playgroud)

VBA

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明