O'Reilly logo

Extending Microsoft Dynamics NAV 2016 Cookbook by Alexander Drogin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sending data to the Excel automation server

The automation datatype in C/AL is frequently used in practice for communication with Microsoft Office applications that export their API through automation servers.

Now we will export the contents of the Customer table from a codeunit using the COM automation library.

How to do it....

  1. Create a new codeunit in the object designer. This will be the object exporting data through an automation server.
  2. Triggering OnRun of the codeunit will instantiate the automation server and iterate on records of the Customer table to export each of them. First declare local variables in the trigger:

    Name

    DataType

    Subtype

    Customer

    Record

    Customer

    ExcelApp

    Automation

    Microsoft Excel 16.0 Object Library.Application ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required