Home | Products | PowerPoint | Books | Book Excerpts

Creating a Ribbon


By: Vivek Thangaswamy

Page 2 of 2

Date Created: March 23rd 2009
Last Updated: March 23rd 2009






...Continued from Page 1

  1. Next, select the User Control, and name it UserControl1.cs.



  2. Open the UserControl1.cs file, and add the following namespace references:
    		using System.Windows.Forms;
    		using Office = Microsoft.Office.Core;
    		using PowerPoint = Microsoft.Office.Interop.PowerPoint;
  3. Open the Ribbon1.cs fi le, and add the following namespace references:
    		using System.Windows.Forms;
    		using Office = Microsoft.Office.Core;
    		using PowerPoint = Microsoft.Office.Interop.PowerPoint;
              
  4. Next, add the instance of the User Control and custom task pane to the Ribbon code file:
              // Usercontrol instance to access from the Ribbon
    		private UserControl1 PacktUserControl;
              // Instance for Custom Task Pane to create
              private Microsoft.Office.Tools.CustomTaskPane PacktCustomPane;
              
  5. Next, write the following code to show the custom task pane in the button click event of the Ribbon menu:
              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;
              }
              
  6. On the ValueChanged event of the dateTimePicker , we are writing the code to insert the selected date.
              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());
              }
              }
              

comments powered by Disqus




Subscribe to Indezine
Follow Indezine

Follow Indezine on Pinterest
Share This Page
Bookmark and Share
Translate Page


Like This Page
Like This Site



Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.

Home | PowerPoint | Photoshop | PowerPoint Templates | PowerPoint Tutorials | Blog | Notes | Ezine | Advertise | Feedback | Site Map | About Us | Contact Us

Link to Us | Privacy | Testimonials

PowerPoint Backgrounds | Christian PowerPoint Backgrounds | Business PowerPoint Presentation Templates

Plagiarism will be detected by Copyscape

©2000-2016, Geetesh Bajaj. All rights reserved.

since November 02, 2000