|
-
May 4th, 2004, 12:16 PM
#1
Thread Starter
Junior Member
Problem Calling .NET dll from Excel VBA
Say I have a .NET project to compile to a class library (.DLL). Here is all the code in the library:
Code:
Public Class GetString
Public Function GetTestString() As String
Return "Test String"
End Function
End Class
In the build options, I have selected the library to be Registered for COM Interop. After compiling the project, I get both GetString.dll and GetString.tlb in the \bin folder.
Now in Excel I open a new book. Go to the Vb Editor and add a reference to the GetString.tlb file in the \bin folder of my .NET solution. I then add VBA module and I put the following code:
Code:
Public Sub getStr()
Dim str As New GetString.GetString
Dim ws As Worksheet
Set ws = ActiveSheet
ws.Range("A1").Value = str.GetTestString()
End Sub
Compile -> Save. When I run the macro, everything works perfect! The string is successfully placed in the appropriate cell.
But NOW the part that has confused and frustrated me for a long time. I now take the Excel worksheet, the GetString.dll, and the GetString.tlb file and put them on another computer. The other computer does have .NET installed by the way. When I run the macro, I get the following error: Run-time error '429': ActiveX component can't create the object.
This problem is a much more simplified version of what I am actually dealing with. But If someone could PLEASE tell me the exact steps to take to get this macro to work on a PC other than my own development PC, I would be very greatful.
Thanks,
brazilnut
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|