如何获取幻灯片布局幻灯片的幻灯片类型(类型属性)?

How to get the slidetype (type-attribute) of a slidelayout-slide?

应用程序是一个基于 C# 的 VSTO-AddIn for PowerPoint。

powerpoint 中的每个 SlideLayout 都有一个类型。有没有办法在 VSTO-AddIn 中获取类型?到目前为止,我只知道如何从 SlideLayout.xml

中获取它

是的,PowerPoint 对象模型公开了一个枚举PpSlideLayout,所以类似于

PowerPoint.PpSlideLayout theLayout = theSlide.Layout;

这是创建新幻灯片的代码片段(需要分配 CustomLayout),显示自定义布局和 PpSlideLayout 的字符串值,然后分配不同的 PpSlideLayout

PowerPoint.Presentation p = this.Application.ActivePresentation; 
PowerPoint.PpSlideLayout layoutBlank = PowerPoint.PpSlideLayout.ppLayoutBlank;
PowerPoint.CustomLayout custLayout = p.SlideMaster.CustomLayouts[1];
PowerPoint.Slide s = p.Slides.AddSlide(2, custLayout);
System.Windows.Forms.MessageBox.Show(s.CustomLayout.Name + ", " + s.Layout.ToString());
s.Layout = layoutBlank;