External Interfaces/API Reference |
Create a COM Automation server and return a COM object for the server's default interface
Syntax
Arguments
progid
This is a string that is the name of the control to instantiate. This string is provided by the control or server vendor and should be obtained from the vendor's documentation. For example, the progid
for MATLAB is matlab.application
.
machinename
This is the name of a remote machine on which the server is to be run. This argument is optional and is used only in environments that support Distributed Component Object Model (DCOM) -- see Using MATLAB As a DCOM Server Client in the External Interfaces documentation. This can be an IP address or a DNS name.
Description
Create a COM Automation server and return a COM object that represents the server's default interface. Local/Remote servers differ from controls in that they are run in a separate address space (and possibly on a separate machine) and are not part of the MATLAB process. Additionally, any user interface that they display will be in a separate window and will not be attached to the MATLAB process. Examples of local servers are Microsoft Excel and Microsoft Word. There is currently no support for events generated from automation servers.
Examples
Launch Microsoft Excel and make the main frame window visible:
Call the get
method on the excel
object to list all properties of the application:
get(e) ans = Application: [1x1 Interface.excel.application.Application] Creator: 'xlCreatorCode' Parent: [1x1 Interface.Excel.Application.Parent] Workbooks: [1x1 Interface.excel.application.Workbooks] UsableHeight: 666.7500 . .
List all methods for that interface by calling invoke
with just the handle argument:
invoke(eWorkbooks) ans = 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)'
Invoke the Add
method on workbooks
to add a new workbook, also creating a new interface:
Quit the application and delete the object:
See Also
actxcontrol
, release
, delete
, save
, load
actxcontrol | addproperty (COM) |