This documentation is archived and is not being maintained.

Using Windows Forms Controls on Word Documents

You can add Windows Forms controls to a Microsoft Office Word document in the same manner that you add controls to Windows Forms. However, there are some differences in the way that Windows Forms controls behave on documents. 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 application-level projects for Word 2007 and Word 2010. For more information, see Features Available by Office Application and Project Type.

There are a few considerations that are specific to Word.

Layout Style

When you add a control to the Word document in a document-level project by using the Visual Studio designer, the control is added in line with text. To change the layout style of the control, right-click the control and then click Format Control. Select a wrapping style on the Layout page of the Format Object dialog box.

When you add a control to a Word document at run time, you can specify the layout style of the new control by using different Add<control class> method overloads of the Microsoft.Office.Tools.Word.ControlCollection class:

  • To add the control in line with text, use an overload that accepts a Range that specifies the location of the control.

  • To add the control as a floating shape, use an overload that accepts the left and top coordinates of the control.

For more information, see Adding Controls to Office Documents at Run Time and Helper Methods for Windows Forms Controls.

If you open a Word template in the Visual Studio designer, non-inline controls on the template might not be visible because Visual Studio opens the template in Normal view. To view the controls, change the view to Print Layout.

Controls Outside the Main Document Body

Windows Forms controls are not supported inside of a header or footer, or within a subdocument.