Microsoft Office Tutorials and References
In Depth Information
Dynamically add a slide and set title text in the presentation
Dynamically add a slide and set title text in
the presentation
The VSTO application-level add-in is slightly different for Microsoft Office
PowerPoint 2007. VSTO in PowerPoint doesn't have the ability to recognize the
default presentation during the startup procedure. This is not a limitation of VSTO in
PowerPoint; it is the default behavior of VSTO programming for PowerPoint 2007.
Zack has another task at hand—to create a presentation using PowerPoint 2007,
where the presentation should be loaded with a slide and have some text added to
it by default. Knowing the default behavior of the VSTO application level add-in for
PowerPoint 2007, Zack came up with a solution for this scenario.
VSTO exposes many objects, classes, and events for PowerPoint 2007 programming.
Using events exposed by VSTO, you can achieve the solution for this scenario. Zack
used the AfterNewPresentation event and developed a solution for it. Let's follow
up the procedure and learn how to create a presentation and add a slide to it with
text content.
Open Visual Studio 2008 and create a new solution, as described earlier. In
the ThisAddIn.cs file, write the following program to add a title slide to the
presentation in Microsoft Office PowerPoint 2007:
// PowerPoint application object instance
PowerPoint.Application PacktPowerPointApplication;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
// Get access to the instance of current application
PacktPowerPointApplication = this.Application;
// Registering the AfterNewPresentation event of the PowerPoint
PacktPowerPointApplication.AfterNewPresentation +=
new PowerPoint.EApplication_
// AfterNewPresentation event of PowerPoint presentation
private void PacktPowerPointApplication_AfterNewPresentation(
PowerPoint.Presentation PacktPresentation)
// Call the custom function to add slide with text on it
// Custom function to add slide with text
private void Packt_AddSlides(PowerPoint.Presentation
Search JabSto ::

Custom Search