vb.net - 访问事件窗口中的自定义任务 Pane - Visual Basic、VSTO

标签 vb.net vsto powerpoint

我正在 VSTO 中为 Ppt 2013 创建 COM 加载项,但在引用事件窗口中的自定义任务 Pane 时遇到问题。

我的代码应该使自定义任务 Pane 仅对事件窗口可见,但它当前对所有文档窗口运行。

我的代码是:

For Each CTP As Microsoft.Office.Tools.CustomTaskPane In Globals.ThisAddIn.CustomTaskPanes

        If CTP.Window Is Globals.ThisAddIn.Application.ActiveWindow Then
            CTP.Visible = True
        End If

    Next

任务 Pane 将添加到使用以下代码创建/打开的每个新演示文稿中

AddIn_control1 = New AddIn_control
AddIn_taskpane = Me.CustomTaskPanes.add(AddIn_control1, "Add-in taskpane", Me.Application.ActiveWindow)

最佳答案

我做了一个小实验,结果发现 CustomTaskPane.Window 始终是 ActiveWindow。因此,要解决此问题,您可以在某些字典中继续跟踪粘板:

Dictionary<CustomTaskPane, PowerPoint.Presentation> ctpDict = new Dictionary<CustomTaskPane, PowerPoint.Presentation>();
void Application_AfterNewPresentation(PowerPoint.Presentation Pres) {
    AddIn_control AddIn_control1 = new AddIn_control();
    CustomTaskPane AddIn_taskpane = this.CustomTaskPanes.Add(AddIn_control1, "Add-In Taskpane", this.Application.ActiveWindow);
    ctpDict.Add(AddIn_taskpane, Pres);
}

稍后您可以使用它:

if (cptDict[CTP] == Globals.ThisAddIn.Application.ActivePresentation) {
    CTP.Visible = true;
}

关于vb.net - 访问事件窗口中的自定义任务 Pane - Visual Basic、VSTO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34677429/

相关文章:

email - 检测电子邮件是否本质上是文本

javascript - 即使指定 mime 类型也无法上传 .ppt 文件

javascript - 包括特定于 ASP.NET MVC4 View 或部分 View 的脚本

.net - 无论版本如何,如何引用 DLL?

c# - 在 VS2013 中的项目之间共享设置文件

对象数组的 VB.NET 语法

c# - VSTO - C# 中的 Outlook 事件处理程序

c# - 为多个应用程序创建 VSTO 插件

vba - 在 PowerPoint 中按占位符名称处理形状

c# - 如何在 ASP.NET MVC 中读取 PPT 文件?