public void CTPFactoryAvailable(object CTPFactoryInst) { try { Office.ICTPFactory ctpFactory = COMObject.CreateFromParent <Office.ICTPFactory>(_accessApplication, CTPFactoryInst); Office._CustomTaskPane taskPane = ctpFactory.CreateCTP(typeof(Addin).Assembly.GetName().Name + ".SampleControl", "NetOffice Sample Pane(CS4)", Type.Missing); taskPane.DockPosition = MsoCTPDockPosition.msoCTPDockPositionRight; taskPane.Width = 300; taskPane.Visible = true; _sampleControl = taskPane.ContentControl as SampleControl; ctpFactory.Dispose(); } catch (Exception exception) { string message = string.Format("An error occured.{0}{0}{1}", Environment.NewLine, exception.Message); MessageBox.Show(message, _progId, MessageBoxButtons.OK, MessageBoxIcon.Error); } }