Page tree
Skip to end of metadata
Go to start of metadata

Table of Contents

Intro

Icon

This is Part 3 of a 3-part tutorial series for the Project Proposal scenario. It is recommended that you complete Part 1 - Getting Started and Part 2 - Repeat Behavior before starting this section.

Following the Sample

Icon

There is a downloadable PowerPointWriter_BasicTutorials.zip with completed templates and code. The completed example of the template is available under ProjectProposal/templates/part3_template.pptx. The code for this part of the tutorial can be found in Part3.aspx.cs.

This part focuses on passing a presentation between PowerPointTemplate and PowerPointApplication in order to take advantage of the full range of features available with PowerPointWriter.

Adding to the Template

Add a new slide to the template from Part 2. This slide will be an optional extra slide that could be removed if necessary, for instance if the presentation was a draft. In this example, we will show you how to remove an optional slide.

The extra slide in the template file look like the following:

Passing between Template and Application

In order to delete this slide we will be using PowerPointApplication's Delete method. However, we have so far been working only in PowerPointTemplate. In order to take advantage of the methods in PowerPointApplication, we must first pass the completed template file to PowerPointApplication. This will be done in the Writing the Code section of this tutorial. See Passing between Template and Application for more information.

Writing the Code

Following the Sample

Icon

There is a downloadable PowerPointWriter_BasicTutorials.zip with completed templates and code. The completed example of the template is available under ProjectProposal/templates/part3_template.pptx. The code for this part of the tutorial can be found in Part3.aspx.cs.

We will reuse the code from Part 1 and Part 2 of this tutorial. We will take out the Save call and add our new code for Part 3.

1. Pass the Template object to PowerPointApplication so that PowerPointApplication methods can be used.

2. We want to delete the last slide in our presentation, so we need to know how many slides there are. We can use Slides.Count to get this information.

3. Use the Slides.Delete method to delete the last slide. It takes an integer representing the index of the slide to delete as a parameter.

4. Save the final presentation and stream it in the response.

Final Code

Icon

For information on writing this code, see Part 1 - Getting Started.

Downloads

You can download the code for the Basic PowerPointWriter Tutorials as a Visual Studio solution, which includes the Project Proposal.

  • No labels