Reputation: 3744
I need to create a PowerPoint 2007 presentation from a template with Open XML Format SDK 2.0. The template has to be provided by the customer and is used for a individual layout style (font, background color or image,...). It needs to contain two predefined slides:
The application should now create a copy of the template file, create multiple copies of the text- and image slides and replace the content-placeholders with some content.
I already found some code snippets from Microsoft to edit the title of a slide, delete them or replace a image on a slide. But i didn't find out how i can create a copy of a existing slide. Maybe somebody can help me with this.
Upvotes: 5
Views: 9715
Reputation: 676
For C#
File.Copy(SourceFile,ExportedFile);
You basically keep the original file.
Now you open ExportedFile
PowerPoint.Application ppApp = new PowerPoint.Application();
PowerPoint.Presentation presentation;
presentation = ppApp.Presentations.Open(ExportedFile, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
Now iterate all slides/shapes
foreach (PowerPoint.Slide slide in presentation.Slides)
{
slide.Select();
foreach (PowerPoint.Shape shape in slide.Shapes)
{
if (shape.Type.ToString().Equals("<any type of shape>"))
{
if (shape.TextFrame.TextRange.Text.Equals("<contains a name"))
{
shape.TextFrame.TextRange.Text = <new value>;
shape.Delete(); // or delete
shape.AddPicture(<your new picture>, MsoTriState.msoTrue, MsoTriState.msoTrue, left, top, width, height);
}
}
}
}
Hope this might clarify your request.
Upvotes: 0
Reputation: 29153
This is an example of what I thing you're looking for, but if not, let me know: http://openxmldeveloper.org/articles/7429.aspx
Upvotes: 0
Reputation: 2262
I have been looking around for a similar answer and have found some resources to share:
http://msdn.microsoft.com/en-us/library/cc850834(office.14).aspx
or more samples
http://msdn.microsoft.com/en-us/library/cc850828(office.14).aspx
or this website
http://www.openxmldeveloper.com
There is also this free book documenting the OpenXML standard which was somewhat helpful.
Upvotes: 1