Read an exclusive book excerpt from VSTO 3.0 for Office 2007 Programming is presented here with permission from Packt Publishing.
Author: Vivek Thangaswamy
Product/Version: PowerPoint
using System.Windows.Forms;
using Office = Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using System.Windows.Forms;
using Office = Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
// Usercontrol instance to access from the Ribbon
private UserControl1 PacktUserControl;
// Instance for Custom Task Pane to create
private Microsoft.Office.Tools.CustomTaskPane PacktCustomPane;
private void RibbonButton1_Click(object sender,
RibbonControlEventArgs e)
{
// Initializing the UserControl in the ribbon
PacktUserControl = new UserControl1();
// Add the UserControl to the custom task pane
PacktCustomPane = Globals.ThisAddIn.CustomTaskPanes.
Add(PacktUserControl, "Calendar");
// Set the custom task pane to visible
PacktCustomPane.Visible = true;
}
private void dateTimePicker1_ValueChanged(object sender,
EventArgs e)
{
try
{
// Getting the active presentation slide
PowerPoint.Slide PckTSlide = Globals.ThisAddIn.
Application.ActivePresentation.Slides[1];
// Set the presentation type like text or image imsert option
PacktTextShape = PckTSlide.Shapes.AddTextbox(Office.
MsoTextOrientation.msoTextOrientationHorizontal,
50, 100, 600, 50);
// Set the text value as selected date time
PacktTextShape.TextFrame.TextRange.Text = dateTimePicker1.
Value.ToString();
// Font style properties
PacktTextShape.TextFrame.TextRange.Font.Size = 48;
PacktTextShape.TextFrame.TextRange.Font.Color.RGB = Color.
DarkViolet.ToArgb();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
You May Also Like: How to Use PowerPoint Differently: 3 Unique Use Cases | Flags and Maps - O PowerPoint Templates
This is the original page. An AMP (Accelerated Mobile Page) version of this page is also available for those on mobile platforms, at Creating a Ribbon in PowerPoint - 2 of 2.
Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.