21

Excel Automation Add-ins

21.1 INTRODUCTION AND OBJECTIVES

In this chapter we discuss how to manipulate the objects in the Excel application object model. This is called Automation and it is a generic term that allows a host application (or automation client) to access the objects in a target application (or automation server). All the Office applications can be used as automation servers and in this chapter we concentrate on Excel.

We give a global overview of the design principles underlying Automation and we introduce and define a number of concepts before we actually create an Automation add-in. We describe the steps at a high level and we then present a number of examples. We have used these add-ins in applications in Chapters 12, 15, 16 and 17.

We conclude this chapter by discussing how to call Automation add-in functions from VBA.

21.2 COM OVERVIEW

COM (Component Object Model) is a technology that makes it possible for applications to interact with each other and to provide components that can be reused in several applications. COM components can be created and used in several programming languages that provide COM support. For example, a COM component could be written in C++ and used from VBA.

COM is the basis for several other technologies such as OLE2 (Object Linking and Embedding), Automation and ActiveX controls.

COM software implements its services as one or more COM objects. Each COM object implements one or more interfaces. Applications use a COM object via the ...

Get C# for Financial Markets now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.