1

I have problem with one CustomTaskPane in mutiple Excel 2016 documents. I create and display task pane with my WinForm user control

 Dim cll As cMyControl = New cMyControl

 Private Sub ThisAddIn_Startup() Handles Me.Startup
    CustomTaskPanes.Add(cll, "Panel")
 End Sub

This panel I can see in all workbook.

Private Sub Application_WorkbookActivate(Wb As Microsoft.Office.Interop.Excel.Workbook) Handles Application.WorkbookActivate
    CustomTaskPanes.RemoveAt(0)
    CustomTaskPanes.Add(cll, "Panel")
End Sub

The problem is that the panel is created but empty. Is any way how to transfer user control between CustomTaskPanels? Or how to attach created panel to another Excel window? Because the I don't want to create new cll object for each workbook activation.

milos
  • 103
  • 1
  • 11

1 Answers1

0

Excel 2016 is a SDI and then you need to store a reference of each taskpane. You need to use Globals.ThisAddIn.Application.Hwnd to identify the Excel window.

See here for a solution : https://stackoverflow.com/a/24732000/3205529

Graham
  • 7,431
  • 18
  • 59
  • 84
Malick
  • 6,252
  • 2
  • 46
  • 59
  • If I understand correctly, this create unique custom task pane for each window (with unique new user control). But I need something like new task pane with the current user control (all user changes in user control will be maintained). – milos Sep 24 '16 at 13:14