Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

ocx or dll file

Dear Experts
I design two functions which return string for VBA and using them in MS Word.
now I want to store these function out side of ms word. means in an OCX or DLL file please guide me which one will be best and also how to design if u can guide or link me to a good tutor for that.

thanks
0
SCS_SU
Asked:
SCS_SU
  • 4
  • 3
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
A dll is a component/library that contains only code (subs, functions and classes). Whereas an ocx is an ActiveX control that you would place on a form, much like you would with a command button or textbox.

An ActiveX dll is fairly simple to create.

This tutorial should help you get started:

    http://www.tutorial-web.com/asp/dll/


Hope this helps.
0
 
SCS_SUAuthor Commented:
I want to access these function from VBA ms word.
demo looks as my function
I get argument and then return some value

Function AdditionFunction(FirstNumber, SecondNumber)
    AdditionFunction = FirstNumber + SecondNumber
End Function

lik looks nice
0
 
Carl TawnSystems and Integration DeveloperCommented:
Once you have create an ActiveX dll (containing a class module) you need to create an instance of it in your VBA app using code like:

    Set oSomeObject = CreateObject("YourComponent.YourClassName")

You can then call your functions with code something like:

    myVal = oSomeObject.AdditionFunction(5, 10)


Hope this helps.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
s_sansanwalCommented:
Register it before using in VBA
run regsvr32.exe yourDll.dll
and then use the code written by Carl
0
 
SCS_SUAuthor Commented:
ohh I select a activex dll template in vb and in a class i put all my function. now wat to do.
also as in ms word template every body can see codes then how to restrict to not use this dll.

0
 
Carl TawnSystems and Integration DeveloperCommented:
next you make your dll.  Then in you Word VBA project you add a reference to you dll using the Project > References menu.  To create an use an object in your dll you use something like:

    Dim myObj As New YourProjectName.YourClassName

    '// Call a method of your object
    myObj.DoSomething
0
 
SCS_SUAuthor Commented:
yes thanks it works fine but a little more in this

I have about 5 differnt types of functionalities in this
each function contain some other functions help and when I seprate them in modules it is ok but in calling user interface I just have function that I define in main class and if I define all functions in that it looks too heavy to handle so I want to make seprate modules for diff: catagories but want to allow my dll to show them too.

I tried to make them public but they allso do not work.
0
 
Carl TawnSystems and Integration DeveloperCommented:
To do that you would have to put a function in your class that calls the relevant function in your module. The only functions that are exposed directly to the user are the ones in the class that are Public.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now