MATLAB: Do I receive “Excel primary interop assembly is not found” error when creating Excel add-in client for MPS

MATLAB Production Server

I am unable to compile an Excel add-in client for MATLAB Production Server (MPS) when using the Windows SDK 7.1 compiler and instead receive the below compilation error:
Excel primary interop assembly is not found.

Best Answer

Compiling the MPS Excel add-in works differently than a regular Excel add-in. It requires the Microsoft Office Primary Interop Assembly package. This can be obtained in the following ways:
1. Installed with Visual Studio
2. For Office 2007 or Office 2010, it can be installed if the ".NET Programmability Support" box is checked during installation
3. For Office 2013 or later, it is installed by default with Office.
4. Downloaded directly from Microsoft's site:
For more information, check:
However, MATLAB only sees the assembly if it is installed with Visual Studio (first case above). As such, the error manifests if you try to use Windows SDK 7.1 without Visual Studio installed. To fix the error, the interop assembly needs to be copied from the Global Assembly Cache (GAC) to the Visual Studio folder. To do this:
1. Make sure that the interop assemblies are installed through one of the methods above. This can be confirmed by opening the folder at:
C:\Windows\assembly
and see if Microsoft.Office.Interop.Excel is listed. Note the Version and the Public Key Token values. Version could be 12.x.x.x (Office 2007), 14.x.x.x (Office 2010), or 15.x.x.x (Office 2013).
2. Open the Windows Command Prompt and run the following command:
copy "C:\Windows\Assembly\GAC_MSIL\Microsoft.Office.Interop.Excel\<Version>__<Public_Key_Token>\Microsoft.Office.Interop.Excel.dll" "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\<OfficeVersion>"
Note the <Version> and <Public_Key_Token> placeholders above. They should be the same as the values seen in Step 1. Depending on whether you have Office 2007 or Office 2010, <OfficeVersion> should be "Office12" or "Office14" respectively. With Office 2013, you can use the following destination path:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office15
The destination folder should be created manually if it does not exist.