void AddTaskPane(Excel.Workbook wb) { myUserControl1 = new TagUIExcelAddInTaskPane(); myUserControl1.Name = wb.Name; taskPaneValue = this.CustomTaskPanes.Add(myUserControl1, " ", wb.Application.ActiveWindow); DocumentProperties prps; prps = (DocumentProperties)Globals.ThisAddIn.Application.ActiveWorkbook.CustomDocumentProperties; if (ReadDocumentProperty("customTaskPaneName") != null) { prps["customTaskPaneName"].Delete(); } prps.Add("customTaskPaneName", false, MsoDocProperties.msoPropertyTypeString, myUserControl1.Name); taskPaneValue.VisibleChanged += new EventHandler(taskPaneValue_VisibleChanged); }
void AddTaskPane(Word.Document Doc) { taskPaneControl1 = new TagUITaskPane(); taskPaneControl1.Name = Doc.Name; taskPaneValue = this.CustomTaskPanes.Add(taskPaneControl1, " ", Doc.ActiveWindow); DocumentProperties prps; try { prps = (DocumentProperties)Globals.ThisAddIn.Application.ActiveDocument.CustomDocumentProperties; if (ReadDocumentProperty("customTaskPaneName") != null) { prps["customTaskPaneName"].Delete(); } prps.Add("customTaskPaneName", false, MsoDocProperties.msoPropertyTypeString, taskPaneControl1.Name); taskPaneValue.VisibleChanged += new EventHandler(taskPaneValue_VisibleChanged); } catch { } }