PowerPoint VSTO插件应用ThemeColorScheme.Load后幻灯片渲染异常求助
PowerPoint VSTO插件中
ThemeColorScheme.Load应用配色方案的渲染问题 在Office VSTO插件中使用ThemeColorScheme.Load(colorSchemeFile)应用配色方案时,出现部分幻灯片无法正确渲染的问题:幻灯片缩略窗格中所有幻灯片均显示正确的配色方案,执行加载操作时选中的幻灯片能正确应用,但其余幻灯片渲染行为不一致;即使仅含两张幻灯片,未选中的那张也始终无法正确渲染。
复现步骤
- 在Visual Studio中创建PowerPoint VSTO插件项目;
- 创建带按钮的用户控件,点击按钮切换当前演示文稿幻灯片的配色方案(也曾尝试通过
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); } } } }%localappdata%\Temp\PowerPointAddIn,测试用的两种配色方案(Test Dark、Test Light)及演示文稿均在复现仓库根目录。 - 将创建的用户控件添加到任务窗格;
代码示例: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 } } - 使用至少包含两张幻灯片的演示文稿调试插件。
问题
请问这是已知问题吗?若为已知问题,是否有正确应用配色方案文件的其他方法?
内容的提问来源于stack exchange,提问作者cedsan
相关产品推荐
相关产品推荐

