|
-
Apr 5th, 2010, 04:14 AM
#1
Thread Starter
New Member
VB.Net DLL in VBA
Hi
somebody please help me, how to access the DLL created in VB.Net from VBA. I created the class library in VB.Net2008. It works fine if I call the DLL from another VB.Net program. When I try to use it in VBA, it is not working, when I searched other websites, there are some many confusing explanations about COM, compile, etc.
I have a function
Class1
private function adduk(a as integer, b as integer)
dim c as integer
c=a+b
return c
End Function
End Class1
In VBA I called the dll as
Public Declare Function additionuk Lib "d:\ClassLibrary1.dll" (aa As Integer, bb As Integer) As Integer
and in the main module I called like
c = adduk(a,b)
But it is not working. Somebody please help me how to find a solution.
Thanks
Deuche
-
Apr 5th, 2010, 04:54 AM
#2
Re: VB.Net DLL in VBA
I assume that is a simplified example? If not then why bother with a DLL in the first place - just put that code in your VBA project.
I haven't used VBA for a long time but I assume its still COM based, in which case you'll need to enable COM interop. Go to your projects properties.. on the application tab click "Assembly Information" and then make sure "Make assembly COM-visible" is checked.
-
Apr 5th, 2010, 05:04 AM
#3
Thread Starter
New Member
Re: VB.Net DLL in VBA
 Originally Posted by keystone_paul
I assume that is a simplified example? If not then why bother with a DLL in the first place - just put that code in your VBA project.
I haven't used VBA for a long time but I assume its still COM based, in which case you'll need to enable COM interop. Go to your projects properties.. on the application tab click "Assembly Information" and then make sure "Make assembly COM-visible" is checked.
Hi keystone_paul,
Thanks for your reply. I gave here a small example to understand the process. In my project it has so many functions which are used for Hardware interfaces. I don't want to confuse others with my big codes.
I tried the same way you explained "COM-visible", it is enabled and built the DLL file. I don't know how to call the DLL and its function in VBA.
Thanks
Deuche
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
|