?
Solved

ocx or dll file

Posted on 2004-08-03
8
Medium Priority
?
250 Views
Last Modified: 2010-05-02
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
Comment
Question by:SCS_SU
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 11710454
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
 

Author Comment

by:SCS_SU
ID: 11710628
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
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 11710670
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Expert Comment

by:s_sansanwal
ID: 11711237
Register it before using in VBA
run regsvr32.exe yourDll.dll
and then use the code written by Carl
0
 

Author Comment

by:SCS_SU
ID: 11739121
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
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 60 total points
ID: 11739428
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
 

Author Comment

by:SCS_SU
ID: 11811986
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
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 11812374
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

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question