To implement Automation with C/SIDE, you create an Automation controller in C/AL code of your Microsoft Dynamics NAV 2009 object. By using variables that have an Automation data type, an Automation controller implements and run Automation objects from an Automation server. This topic outlines the procedure for creating an Automation controller.

To create an Automation controller that uses an Automation server

  1. Declare the creatable (top-level) interface (class) of the Automation server as a variable of the Automation data type.

  2. Declare all other objects and interfaces (classes) as variables of the Automation data type.

  3. Use the C/AL CREATE function on the variable that you declared in step 1. Do not use the CREATE function on any other variables.

    If you are creating an Automation controller for the RoleTailored client, then you use the CREATE function to specify whether to run Automation objects on the RoleTailored client or on Microsoft Dynamics NAV Server. For more information, see Best Practices for Using Automation With the RoleTailored Client and CREATE Function (Automation).

  4. Use the methods and properties of the Automation server in your C/AL code.

  5. If needed, use the CLEAR function (destroy) for the top-level object. Otherwise, it will be cleared automatically when the variable goes out of scope.

You write most of your code during step 4 by using the methods and the properties of the Automation server. The syntax and the semantics of these methods and properties are documented in the documentation for each Automation server. Using these methods and properties in C/AL does not require any new or changed syntax.

For examples of creating an Automation controller, see Walkthrough: Using Automation to Write a Letter in Microsoft Office Word and Walkthrough: Using Automation to Create a Graph in Microsoft Excel.

See Also