第1步:创建Excel 2010的外接ActiveX组件不能创建对象VBA运行时错误
我创建了一个新的项目时,Excel 2010加载项,.NET 4.0框架
我加一个类文件,它 “Name.cs” 接口 “iName.cs”,并增加了一个功能,它
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface iName
{
string getName();
}
[ClassInterface(ClassInterfaceType.None)]
public class Name
{
public string getName()
{
return "Hello";
}
}
第2步:配置生成事件
我配置的亲
"%Windir%\Microsoft.NET\Framework\v4.0.30319\regasm" /codebase /tlb
"$(MSBuildProjectDirectory)\$(OutputPath)$(AssemblyName).dll"
构建事件这将注册DLL,以便它会在Excel中
STEP 3 references
列可用:在Excel中添加参考宏
我创建了一个模块,在工具 - >参考中我添加了NameProvider
(该程序集/项目的名称)插件,该插件在构建Excel加载项目后可用
我试图创建一个对象为补充参考
Public Sub test()
Dim nameObj as NameProvider.Name
Dim name as string
Set nameObj = new NameProvider.Name 'error 429 occurs here
name = nameObj.getName() 'getName function automatically comes after .
End Sub
你使用Office 64 ? – dePatinkin
是的,它的64位@dePatinkin –