Thursday, 14 April 2011

How to use a ActiveX VB dll in VBA


Fig1. Toolbar























---------------------------------------------------------------------------------------
To add a Active X VB dll. First go to Tool->reference ->
2.Go Browse and add the selected dll.
3.To access its class function 
----------------------------
Dll Library name:
MyCalculator
Class name: Calculator

Function Name: Add(int ,int)

-----------------------------

To access this dll function:
You need to create an object of this clas s
as
Dim obj1 as New MyCalculator.Calculator
////////////////////////
To access the member function 
obj1.Add(2,3)
------------------------------------------

--------------------------------------------------------------------------
Using C dll in VBA
------------------------------------------------------------------------

To add a c dll
1. Create a module in VBA
2. declare the c dll functions
Public Declare Function Add Lib "C:\example1.dll" (ByVal FirstNum As Long, ByVal secondnum As Double) As Double.


Here Add is my function which is in the dll example1.dll
To know this functiom=n you need to add the full path of the dll and call this function by using their parameters as written in Bold above


The return Type  will be double for the function

No comments:

Post a Comment