[英]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.