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, and h is the handle of the server's default interface.

Get progid from the control or server vendor's 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.

  • The Custom interface name

You must know the name of the interface and have the server vendor's documentation in order to use the interfaceName value. 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.

The following syntaxes are deprecated and will not become obsolete. They are included for reference, but the syntaxes described earlier are preferred:

h = actxserver('progid',machine) creates a COM server running on the remote system named by the machine argument. This 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 Using MATLAB Application as DCOM Server).

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


Microsoft Excel Workbook Example

This example creates an OLE Automation server, Excel® version 9.0, and manipulates a workbook in the application.

Create a COM server running Microsoft Excel.

e = actxserver('Excel.Application')
e =     

Make the Excel frame window visible.

e.Visible = 1;

Use the get method on the Excel object e to list all properties of the application.


Create an interface eWorkBooks.

eWorkbooks = e.Workbooks
eWorkbooks =

List all methods for that interface.

       Add: 'handle Add(handle, [Optional]Variant)'
     Close: 'void Close(handle)'
      Item: 'handle Item(handle, Variant)'
      Open: 'handle Open(handle, string, [Optional]Variant)'
  OpenText: 'void OpenText(handle, string, [Optional]Variant)'

Add a new workbook w, also creating a new interface.

w = Add(eWorkbooks)
w =

Close Excel and delete the server.


More About

collapse 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?