我想使用
ThemeColorScheme.Load(colorSchemeFile)
在 Office VSTO 加载项中应用配色方案,但并非所有幻灯片都显示应用的配色方案。在幻灯片缩略图窗格中,所有幻灯片都显示为应用了正确的配色方案,并且所选幻灯片(执行 ThemeColorScheme.Load
操作时)也将应用正确的配色方案,但如果经过多次测试,其余幻灯片的行为会不一致演示文稿中有不同的幻灯片,但即使有两张幻灯片,也总是无法正确呈现未选择的幻灯片。
我已经创建了一个 repo 可以被克隆来重现这个问题,但主要的事情是:
presentation.Designs[i].SlideMaster.Theme.ThemeColorScheme.Load
应用颜色主题,但产生了相同的结果 using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace UserControls
{
public partial class UserControl1 : UserControl
{
private readonly string[] availableColorThemes = { "Test Dark", "Test Light" };
private string currentTheme;
private Microsoft.Office.Interop.PowerPoint.Application application;
public UserControl1(Microsoft.Office.Interop.PowerPoint.Application application)
{
InitializeComponent();
this.application = application;
currentTheme = "Test Light";
}
private void button1_Click(object sender, EventArgs e)
{
var presentation = application.ActivePresentation;
currentTheme = availableColorThemes.Where(c => c != currentTheme).First();
string fileName = Path.Combine(Path.GetTempPath(), "PowerPointAddIn", $"{currentTheme}.xml");
for (var i = 1; i <= presentation.Slides.Count; i++)
{
presentation.Slides[i].ThemeColorScheme.Load(fileName);
presentation.Designs[i].SlideMaster.Theme.ThemeColorScheme.Load(fileName);
}
}
}
}
在我链接的复制存储库中,代码正在从
%localappdata%\Temp\PowerPointAddIn
读取配色方案文件,我使用的两种配色方案(Test Dark,Test Light)位于存储库根目录以及测试演示(Test Presentation)中。
using UserControls;
namespace PowerPointAddIn2
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
UserControl1 userControl1 = new UserControl1(Application);
Microsoft.Office.Tools.CustomTaskPane myCustomTaskPaneContainer =
CustomTaskPanes.Add(userControl1, "My Custom Task Pane");
myCustomTaskPaneContainer.Visible = true;
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
这是一个已知问题吗?如果是这样,是否有另一种正确应用配色方案文件的方法?
感谢任何帮助