Click here to Skip to main content
Click here to Skip to main content

Create a PowerPoint presentation using a template

, 10 Nov 2006
Rate this:
Please Sign up or sign in to vote.
Create a PowerPoint presentation using a template using the Office 2007 OpenXML format.

Sample Image


In this article, I am trying to explain the PowerPoint 2007 file format and its structure by showing how to create a presentation using a template. This is a very useful example and can be used for various purposes. In this example, I am creating slides as per the user input for text and images. The class presentation in the code is designed in a way that anyone can automate the process of generating a presentation by feeding input from any source.


Office 2007 has introduced a new file format called OpenXML. All the data/setting/metadata is stored in an XML file. First, quickly create a Word/Excel/PowerPoint file and save it. Now, close the application and rename the file with the extension .zip and open the file. You can see that all the .xml files are packed in there. Microsoft has released the September CTP for .NET Framework 3.0. It has an assembly called Windowbase.dll that has the namespace System.IO.Packaging that supports the Open Office 2007 package file to perform operations like adding/deleting parts and media. You can download it from here. I have used this namespace to work with this example. For further information about Office 2007 OpenXML file format, please read this article. You can get other resources from the online MSDN.

Using the code

In the code, I have written a class presentation that you can find in Presentation.cs. This class uses the System.IO.Packaging namespace. I have the template1.pptx file that you can find in the debug\bin\Template\ folder. I kept the file there just for ease of work. This program creates a copy of the file at the location input by the user (the program asks for the location on hitting the Create presentation button on the main form). Then, for each slide, it creates a copy of slide1.xml and gives it a name in sequence, like slide2.xml etc. Then, this program finds the node where it stores the text and replaces with the text that the user has keyed in, and then adds the image to the package and creates a relationship with the recently created slide(n).xml. It creates an entry of the created slide in presentation.xml and it also creates the relationship with slidelayout(n).xml. At the end, we save the package. The package class has a Save method to compress back the file, and that is it.

//open the package
package = Package.Open(filename, 

Points of Interest

This can be your first example to learn about the PowerPoint file format. If you understand the file format very well, you can change this example to meet your needs.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Web Developer
United States United States
.Net System Designer working in USA with IT company since Jan-2005. I am having experience in Development of office application,Database application ,Java Application, and Banking Solutions.
I am having total 7.5 years of experience in IT. I have done various project for Wireless,Mobile tech.

Comments and Discussions

QuestionHow can i delete a slide using the same code style PinmemberOmda24069024-Apr-14 8:34 
QuestionMessage Automatically Removed PinmemberJamie Calops21-Oct-13 21:59 
SuggestionCorrection PinmemberMember 918313522-Aug-12 19:01 
QuestionDo other image files work? PinmemberMember 79783461-Apr-12 6:00 
QuestionIs it possible in server side? Pinmemberwinsrividhya11-May-10 4:07 
AnswerRe: Is it possible in server side? Pinmemberyusufelik11-Jan-12 3:26 
QuestionPowerpoint in serverside Pinmemberummu 27-Mar-10 19:45 
GeneralIs it posible to extract images,cliparts and vidoes from PPTX file Pinmemberbloremohan2-Dec-08 9:03 
GeneralRe: Is it posible to extract images,cliparts and vidoes from PPTX file Pinmemberyusufelik11-Jan-12 3:25 
GeneralDynamic XML template-based PowerPointCreator in C# PinmemberElmue29-Aug-08 13:05 
GeneralDoesn't work PinmemberJSBBS29-Jun-08 18:57 
GeneralDifferent Image and media at same presentation .. PinmemberMrHoSo14-Mar-08 6:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 10 Nov 2006
Article Copyright 2006 by sharadbajaj
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid