[英]Select into view a slide master page with PowerPoint Interop
在C#中使用的PowerPoint Interop中,是否可以像选择普通幻灯片一样以编程方式选择要显示的幻灯片母版页? 通过提供该母版页的ID或从以其为模板的幻灯片中提供ID。
我设法将视图切换到幻灯片母版:
_pptApplication.ActiveWindow.ViewType = PpViewType.ppViewMasterThumbnails;
我尝试先选择一张幻灯片,然后再切换到母版视图,但是此说明始终将第一个幻灯片母版页置于视图中,而不是与所选幻灯片相关联的页面。
同样,我想知道笔记,讲义及其主人是否可行。
除了已经确定的.ViewType设置之外,还需要在CustomLayout对象上使用.Select()方法。
这是两个示例:
using NetOffice.OfficeApi.Enums;
using NetOffice.PowerPointApi.Enums;
using System;
using PowerPoint = NetOffice.PowerPointApi;
namespace ExportSlides
{
class Program
{
static void Main(string[] args)
{
using (var app = PowerPoint.Application.GetActiveInstance())
{
SelectSlideMasterLayoutOfActiveSlide(app);
ActiveSlideMasterLayoutByIndex(app.ActivePresentation, 4);
}
}
private static void ActiveSlideMasterLayoutByIndex(PowerPoint.Presentation activePresentation, int customLayoutIndex)
{
activePresentation.Windows[1].ViewType = PpViewType.ppViewSlideMaster; //PpViewType.ppViewMasterThumbnails doesn't work for me for some reason
activePresentation.SlideMaster.CustomLayouts[customLayoutIndex].Select();
}
private static void SelectSlideMasterLayoutOfActiveSlide(PowerPoint.Application app)
{
var activeWindow = app.ActiveWindow;
var slideObj = activeWindow.View.Slide;
if (slideObj.GetType() == typeof(PowerPoint.Slide))
{
var slide = (PowerPoint.Slide)slideObj;
activeWindow.ViewType = PpViewType.ppViewSlideMaster; //PpViewType.ppViewMasterThumbnails doesn't work for me for some reason
slide.CustomLayout.Select();
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.