Create COM server


h = actxserver('progid')
h = actxserver('progid','machine','machineName')
h = actxserver('progid','interface','interfaceName')
h = actxserver('progid','machine','machineName','interface','interfaceName')
h = actxserver('progid',machine)


h = actxserver('progid') creates a local OLE Automation server, where progid is the programmatic identifier of an OLE-compliant COM server. Returns h, a handle to the default interface of the server.

Get progid from the control or server vendor documentation. To see the progid values for MATLAB® software, refer to Programmatic Identifiers.

h = actxserver('progid','machine','machineName') creates an OLE Automation server on a remote machine, where machineName is a string specifying the name of the machine on which to start the server.

h = actxserver('progid','interface','interfaceName') creates a Custom interface server, where interfaceName is a string specifying the interface name of the COM object. Values for interfaceName are

  • IUnknown — Use the IUnknown interface. MATLAB does not support the IUnknown interface with 64-bit MATLAB.

  • The Custom interface name

To use the interfaceName value, you must know the name of the interface and have the server vendor documentation. For information about custom COM servers and interfaces, see COM Server Types.

    Note:   The MATLAB COM Interface does not support invoking functions with optional parameters.

h = actxserver('progid','machine','machineName','interface','interfaceName') creates a Custom interface server on a remote machine.

    Note:   The following syntax is not recommended. Use the previous syntaxes instead.

h = actxserver('progid',machine) creates a COM server running on the remote system named by the machine argument. machine can be an IP address or a DNS name. Use this syntax only in environments that support Distributed Component Object Model (for more information, see MATLAB Application as DCOM Server).

COM functions are available on Microsoft® Windows® systems only.


Create Microsoft Excel Workbook

Create a COM server running Microsoft Excel®.

e = actxserver('Excel.Application');

Make the Excel frame window visible.

e.Visible = 1;

List the properties of the Excel application.


MATLAB displays the properties for your Excel version.

Create an interface eWorkBooks.

eWorkbooks = e.Workbooks;

List all methods for the workbooks interface.


MATLAB displays the methods for your Excel version.

Add a workbook w.

w = Add(eWorkbooks);

Open the Excel frame window. You can manipulate the spreadsheet in the Excel application.

When you are finished with the Excel application, close Excel in MATLAB and delete the server object.


More About

expand all


For components implemented in a dynamic link library (DLL), actxserver creates an in-process server. For components implemented as an executable (EXE), actxserver creates an out-of-process server. Out-of-process servers can be created either on the client system or on any other system on a network that supports DCOM.

If the control implements any Custom interfaces, use the interfaces function to list them, and the invoke function to get a handle to a selected interface.

You can register events for COM servers.

Introduced before R2006a

Was this topic helpful?