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
We will continue adding to our template from Part 2. The next part of our presentation will contain information about the Team the new employee will be working on.
- Add a new title slide to the presentation. Give it the title 'Your Team'.
- Place the data marker %%=Team.Name underneath the title. Our template slide is shown below.
- Add a new content slide. Place the company logo in the bottom right corner.
- The title of this slide will be the data marker %%=Department.TrainingItem
- Create a new list in the body of the slide.
- Place the data marker %%=TrainingItems.Details as the first item in the list.
This is the 8th and final slide in our template. This slide will be used as a template slide for 4 different data sets. To achieve this we will use the Slides.Copy method and the Slide data binding property.
Writing the Code
We will start with an unprocessed template file containing all of the slides from the 3 parts of this tutorial.
- Create a PowerPointApplication object.
- Set a Presentation object to our template file. This allows us to use all of the methods in the PowerPointApplication API including Slides.CopySlide. The following steps will create 3 copies of the last slide.
- Create a Slide object for the last slide in our template.
- Call Slides.CopySlide three times, with each call placing the new slide at the end of the presentation. Now that our presentation contains all of the slides we want, we can pass it to PowerPointTemplate to import the data. See Passing Between Template and Application for more information. We will reuse the code from Part 1 and Part 2 of this tutorial. We will take out the Save call and add then our new code for Part 3. Next, we will bind the data for the slides that were added in part 3.
- Create an array containing the string "TrainingItem". Becuase all of our remaining slides use the same data markers, this array can be used as the column names array for multiple BindData calls.
- Get the data for the first slide in the 'Your Team' section of the presentation. The title of this slide is 'Team Members'. Slide property to scope to the slide we want. In this case, it is the 8th slide in our presentation. In order to keep the 'Team Members' data from populating all of our copied slides, we need to set the
- Set the dataProps Slide property to be 7. Slide uses the 0-indexed position of the slide, so this will scope to slide 8.
- Bind the 'Team Members' data to the presentation. This will take two BindData calls, for the two data sources on the slide.
- Follow these same steps for the remaining slides. Make sure to change the Slide property before each BindData call. The same DataBindingProperties object can be used for all the BindData calls.
- Finally, Process and Save the finished presentation. Congratulations, the tutorial is complete!
You can download the code for the Basic PowerPointWriter Tutorials as a Visual Studio solution, which includes the Project Proposal.