Finance and operations

Compile error: Microsoft.Office.Interop.Excel…

A few months ago I wrote a post on how to convert Excel documents to PDF with X++. Well, that piece of code made it into production! 🙂 But I just notice it does not necessarily compile with Ax Build. 🙁

The code:
Excel Interop error

The error:
The xlApp declaration does not compile because Excel is not installed on the server and AX build can only be completed on the server. If you compile this same piece of code in the AOT on a server that has Excel installed, it compiles without a problem.

Excel Interop syntax error

My solution(s):

  • Install Excel on the server. I am not sure if this will allow AX Build to compile the code, but at least you can then open the AOT after AX build on the server and compile like I described here.
  • Since I could not install Excel on the server, I did the following:
    1. Compile with AX Build on the server.
    2. If you have a compile error related to Microsoft.Office.Interop.Excel, start the server and open the AOT on a terminal server that has Excel installed.
    3. Compile the code with normal F7 compile.
    4. Compile the CIL on the terminal server.

Hope that helps! Let me know in the comments if you know of a better way to solve this.

Leave a Reply

Your email address will not be published. Required fields are marked *