XLL+ Class Library (7.0)

Using WinForms from an add-in

To use WinForms classes from an add-in you need to add a reference to System.Windows.Forms.dll to your project.

  1. Open the Project Settings window.
  2. Select the page "Common Properties/References".
  3. Click "Add New Reference..." (and prepare for a potentially long wait).
  4. On the ".NET" page, select "System.Windows.Forms", and press "OK".

Note that on Visual Studio 2015 and 2017, where there is no "Common Properties/References" node in the Project Properties, you should instead use the Solution Explorer window: select the "References" node under the project node, and right-click it, then select the "Add Reference..." command.

You may find it convenient to also add the following line to your main source file, which will save quite a bit of typing.

using namespace System::Windows::Forms;

To get access to a class that links XLL+ to the .NET Winforms classes, you should also add the following line to your main source file:

#include <xlpclrforms.h>


The ExcelForm managed class acts as a link between Excel and WinForms (by implementing the interface IWin32Window). Create an ExcelForm object, and it will allow the Excel application window to act as the owner of a WinForms form.

// Call a WinForms method, using a new instance of  
// the ExcelForm to create an IWin32Window interface 
// for the main Excel application window.
    gcnew XllPlus::Forms::ExcelForm(),
    "Hello from .NET", ".NET message box", 

See the ClrDemo sample for an example of the use of ExcelForm.

Next: Deploying your .NET assemblies >>