How To Call A VB ActiveX Server From A VBA Application
How To Call A VB ActiveX Server From A VBA Application
Article ID: 185731 - View products that this article applies to.
Retired KB Content Disclaimer This article was previously published under Q185731 Expand all | Collapse all
On This Page
o o SUMMARY MORE INFORMATION Create a Simple ActiveX Component Creating the Client Application REFERENCES Properties Give Feedback
SUMMARY
ActiveX Components (formerly known as ActiveX or Automation "Servers") created in Visual Basic can be used with applications that support the Visual Basic for Applications (VBA) programming language. This article shows you how to create a simple Visual Basic ActiveX Component, and how to use that component in a VBA-based application. Back to the top | Give Feedback
MORE INFORMATION
The first step is to create the ActiveX Component. If you are not familiar with this process, here are several tips that you may find useful. It is considered good practice to test your ActiveX Component in Visual Basic before you try it in your VBA application. If it does not work in Visual Basic, it probably won't work in VBA. Additionally, it is not required that you compile (make .exe or .dll) your component. You can reference a Visual Basic component that is running in the Visual Basic design environment. This approach allows you to test both the server and client sides of your application before compiling the finished product.
6. Insert the following code in the General section of MyClass: 7. Option Explicit 8. 9. Public Function SquareIt(lngNumber As Long) 10. SquareIt = lngNumber ^ 2 End Function 11. On the Run menu, click Start with Full Compile.
REFERENCES
For more information about creating ActiveX components with Visual Basic, refer to the chapter "Creating ActiveX Components" in the Visual Basic "Component Tools Guide" (Professional and Enterprise Editions only). Back to the top | Give Feedback
Properties
Article ID: 185731 - Last Review: June 29, 2004 - Revision: 2.1 APPLIES TO Keywords:
Microsoft Visual Basic 5.0 Learning Edition Microsoft Visual Basic 5.0 Professional Edition Microsoft Visual Basic 5.0 Enterprise Edition Microsoft Visual Basic for Applications 5.0
kbhowto KB185731
Retired KB Content Disclaimer This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.