Use Windows Forms controls on Excel worksheets

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

You can add Windows Forms controls to your Microsoft Office Excel workbooks in the same manner that you add controls to Windows Forms. For general information about working with controls on documents, see Windows Forms controls on Office documents overview.

Applies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Excel. For more information, see Features available by Office application and project type.

Control considerations for Excel

There are a few considerations that are specific to Excel.

Match control size to cell size

You can set the control to be resized automatically when the size of the parent cell is changed. For more information, see How to: Resize controls within Worksheet cells.

Add components that are shared by all worksheets

You can add components that you want to share among all worksheets, such as a DataSet, to the Workbook Designer instead of to the worksheets. The component will appear on the component tray.

Formula for embedding controls

When you select a control in Excel, you will see =EMBED("WinForms.Control.Host","") in the Formula Bar. This text is necessary and should not be deleted.

See also