我花了最近的两天时间尝试让一个基本的VB.NET DLL在VBA中运行。我已经阅读了这个网站上的每一篇帖子,但我仍然得到相同的错误。
- 我创建了一个VB.NET类(我以管理员身份运行Visual Studio)。
我的类:
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Runtime.Interposervices
Imports System.Linq
Public Class TestClass
Function TestMethod(ByVal input as String)
Return "Hello" & input
End Function
End Class
- 我设置了"让程序集可见"
- 我设置了"注册COM互操作性"
我构建并发布了dll
我打开Excel并添加了对dll的引用。
到目前为止,一切都运行良好。
In a sheet I add the below code
Public Sub test() Dim a As TestClass 'Note: Auto fills in once i start typing it in so i know that the DLL there Set a = New TestClass MsgBox (a.TestMethod("World") End Sub
当我尝试运行代码时,出现以下错误:
"ActiveX组件无法创建对象"
我已经尝试了在两台电脑上进行此操作:Win7 64位,Excel 2010 64位,VS 2010和Win7 64位,Excel 2013,VS 2010 64位,但是没有成功。我读到有人收到相同的错误信息,但是似乎没有什么方法可以解决。
是否有人发现我的方法有任何错误?