从模板创建 PowerPoint 2007 演示文稿

5
我需要使用Open XML Format SDK 2.0从模板创建一个PowerPoint 2007演示文稿。模板由客户提供,用于个性化布局样式(字体、背景颜色或图像等)。它需要包含两个预定义幻灯片:
  • 文本幻灯片
  • 图像幻灯片
应用程序现在应该创建模板文件的副本,创建多个文本和图像幻灯片的副本,并将内容占位符替换为一些内容。
我已经找到了一些来自Microsoft的代码段来编辑幻灯片的标题、删除它们或替换幻灯片上的图像。但我还没有找到如何创建现有幻灯片的副本。也许有人可以帮助我解决这个问题。
3个回答

1

1
在你的书链接中,你正在链接到本地文件。=P - Maiku Mori

0

对于C#

File.Copy(SourceFile,ExportedFile);

你基本上保留原始文件。

现在打开导出的文件。

PowerPoint.Application ppApp = new PowerPoint.Application();
PowerPoint.Presentation presentation;
presentation = ppApp.Presentations.Open(ExportedFile, MsoTriState.msoFalse,   MsoTriState.msoTrue, MsoTriState.msoTrue);

现在迭代所有幻灯片/形状

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);

                            }
                        }
                    }

}

希望这能澄清您的请求。


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接