A COM client is a program that manipulates COM objects. These objects can run in the MATLAB® application or can be part of another application that exposes its objects as a programmatic interface to the application.
This section provides examples that show how to use MATLAB as a COM client.
Note: You can also access MATLAB as an Automation server from other applications, such as those written in the Microsoft® Visual Basic® programming language. For information on this technique, see MATLAB COM Automation Server Interface.
To start using COM objects, you need to create the object and get information about it. This section covers the following topics:
Two MATLAB functions enable you to create COM objects:
Creates an instance of a control in a MATLAB figure.
Creates and manipulates objects from MATLAB that are exposed
in an application that supports Automation.
Each function returns a handle to the object's main interface, which you use to access the object's methods, properties, and events, and any other interfaces it provides.
Information about Methods. To list the methods supported by the object
Information about Properties. To list the properties of the object
To see the value of the property
change a property value.
Information about Events. To list the events supported by the object
To get the programmatic identifier (
of a COM control that is already registered on your computer, use
You can also use the ActiveX Control Selector,
displayed with the command
This interface lets you see instances of the controls installed on
For more information on using these commands, see Creating an ActiveX Control.
If your MATLAB program uses a custom control (e.g., one that you have created especially for your application), you must register it with the Microsoft Windows® operating system before you can use it. You can do this from your MATLAB program by issuing an operating system command:
!regsvr32 /s filename.ocx
where filename is the name of the file containing the control. Using this command in your program enables you to provide custom-made controls that you make available to other users by registering the control on their computer when they run your MATLAB program. You might also want to supply versions of a Microsoft ActiveX® control to ensure that all users have the same version.
For more information about registration, see Registering Controls and Servers.