text: Walkthrough: Automating an Application from a Custom Task Pane
  This walkthrough demonstrates how to create a custom task pane that automates Microsoft Office PowerPoint 2007. You will create a custom task pane that inserts dates into a slide when the user clicks a MonthCalendar control that is on the custom task pane.
  This walkthrough illustrates the following tasks:
  Designing the user interface of the custom task pane.
  Automating PowerPoint 2007 from the custom task pane.
  Displaying the custom task pane in PowerPoint 2007.
  Testing your project.
  You need the following components to complete this walkthrough:
  One of these two development environments:
  Microsoft Visual Studio 2005 Tools for the Microsoft Office System (VSTO 2005).
  -or-
  Visual Studio 2005 Professional.
  Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System (VSTO 2005 SE).
  Microsoft Office PowerPoint 2007.
  In this step, you will create an add-in project for PowerPoint 2007.
  To create a new project
  Create a PowerPoint Add-in project with the name MyAddIn. Make sure that you use the PowerPoint Add-in project template for the 2007 Microsoft Office system. For more information, see How to: Create Visual Studio Tools for Office Projects.
  Visual Studio opens the ThisAddIn.cs or ThisAddIn.vb code file and adds the MyAddIn project to Solution Explorer.
  There is no visual designer for custom task panes, but you can design a user control with the layout you want. Later in this walkthrough, you will add the user control to the custom task pane.
  To design the user interface of the custom task pane
  On the Project menu, click Add User Control.
  In the Add New Item dialog box, change the name of the user control to MyUserControl, and click Add.
  The user control opens in the designer.
  From the Common Controls tab of the Toolbox, drag a MonthCalendar control to the user control.
  If the MonthCalendar control is larger than the design surface of the user control, resize the user control to fit the MonthCalendar control.
  The purpose of the add-in is to put a selected date on the first slide of the active presentation. Use the DateChanged event of the control to add the selected date whenever it changes.
  To automate PowerPoint from the custom task pane
  In the designer, double-click the MonthCalendar control.
  The MyUserControl.cs or MyUserControl.vb file opens, and an event handler for the DateChanged event is created.
  Add the following code to the top of the file. This code creates aliases for the Microsoft.Office.Core and Microsoft.Office.Interop.PowerPoint namespaces.
  Add the following code to the
  MyUserControlclass. This code declares an instance of Microsoft.Office.Interop.PowerPoint.Shape as a member of
  MyUserControl. In the following step, you will use this Microsoft.Office.Interop.PowerPoint.Shape to add a text box to a slide in the active presentation.
  Replace the
  monthCalendar1_DateChangedevent handler with the following code. This code adds a text box to the first slide in the active presentation, and then adds the currently selected date to the text box. This code uses the
  Globals.ThisAddInobject to access the object model of PowerPoint 2007.
  private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e) { try { if (textbox != null) { textbox.Delete(); } PowerPoint.Slide slide = Globals.ThisAddIn.Application.ActivePresentation.Slides[1]; textbox = slide.Shapes.AddTextbox( Office.MsoTextOrientation.msoTextOrientationHorizontal, 50, 100, 600, 50); textbox.TextFrame.TextRange.Text = e.Start.ToLongDateString(); textbox.TextFrame.TextRange.Font.Size = 48; textbox.TextFrame.TextRange.Font.Color.RGB = Color.DarkViolet.ToArgb(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
  In Solution Explorer, right-click the MyAddIn project and then click Build. Verify that the project builds without errors.
  To display the custom task pane when the add-in starts, add the user control to the task pane in the Startup event handler of the add-in.
  To display the custom task pane
  In Solution Explorer, expand PowerPoint.
  Right-click ThisAddIn.cs or ThisAddIn.vb and click View Code.
  Add the following code to the
  ThisAddInclass. This code declares an instance of
  MyUserControlas a member of
  ThisAddIn.
  Replace the
  ThisAddIn_Startupevent handler with the following code. This code adds the
  MyUserControlobject to the
  CustomTaskPanesfield and displays the custom task pane.
  When you run the project, PowerPoint 2007 opens and the add-in displays the custom task pane. Click the MonthCalendar control to test the code.
  To test your add-in
  Press F5 to run your project.
  Confirm that the custom task pane is visible.
  Click a date in the MonthCalendar control on the task pane.
  The date is inserted into the first slide in the active presentation.
  You can learn more about how to customize Office UI from these topics:
  Create a custom task pane in an add-in for a different application in the 2007 release of Microsoft Office. For more information about the applications that support custom task panes, see Custom Task Panes Overview.
  Create a custom Ribbon tab by using an add-in. For more information, seeWalkthrough: Binding Data to Controls on a Word Actions Pane Ribbon Extensibility Overview.