Using Windows Forms Controls on Word Documents
Updated: July 2008
The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.
Microsoft Office version
For more information, see Features Available by Application and Project Type.
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.
There are a few considerations that are specific to Word.
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.
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.
To add controls to documents at run time by using an application-level add-in, you must install Visual Studio 2008 Service Pack 1 (SP1).
Controls Outside the Main Document Body
Windows Forms controls are not supported inside of a header or footer, or within a subdocument.