Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
To add an actions pane to a Microsoft Office Word document or a Microsoft Excel workbook, first create a Windows Forms user control. Then, add the user control to the Controls property of the ThisDocument.ActionsPane
field (Word) or ThisWorkbook.ActionsPane
field (Excel) in your project.
Applies to: The information in this topic applies to document-level projects for Excel and Word. For more information, see Features available by Office application and project type.
Note
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Personalize the Visual Studio IDE.
The following procedure shows how to create user control in a Word or Excel project. It also adds a button to the user control that writes text to the document or workbook when it is clicked.
Open your Word or Excel document-level project in Visual Studio.
On the Project menu, click Add New Item.
In the Add New Item dialog box, select Actions Pane Control, name it HelloControl, and click Add.
Note
You can alternatively add a User Control item to your project. The classes generated by the Actions Pane Control and User Control items are functionally equivalent.
From the Windows Forms tab of the Toolbox, drag a Button control onto the control.
Note
If the control is not visible in the designer, double click HelloControl in Solution Explorer.
Add the code to the Click event handler of the button. The following example shows code for a Microsoft Office Word document.
In C#, you must add an event handler for the button click. You can place this code in the HelloControl
constructor after the call to InitializeComponent
.
For information about how to create event handlers, see How to: Create Event Handlers in Office Projects.
public HelloControl()
{
InitializeComponent();
this.button1.Click += new EventHandler(this.button1_Click);
}
To show the actions pane, add the user control to the Controls property of the ThisDocument.ActionsPane
field (Word) or ThisWorkbook.ActionsPane
field (Excel).
Add the following code to the ThisDocument
or ThisWorkbook
class as a class-level declaration (do not add this code to a method).
Add the following code to the ThisDocument_Startup
event handler of the ThisDocument
class or the ThisWorkbook_Startup
event handler of the ThisWorkbook
class.
Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayTraining
Module
Build Office Add-ins for Word - Training
This module walks through development of Office Add-ins for Microsoft Word.
Certification
Microsoft Office Specialist: Word Expert (Office 2019) - Certifications
Demonstrate that you have the skills needed to get the most out of Word 2019 by earning the Microsoft Office Specialist (MOS) Expert certification.