Search code examples
delphiexcel-addinscustomtaskpane

Create excel CustomTaskPane in delphi (add-in)


How to create a simple customtaskpane using Delphi without add-in express and add customtaskpane to excel.

Taskpane will have 1 button(close )

procedure TMyAddin.OnConnection(const Application: IDispatch; ConnectMode: ext_ConnectMode; const AddInInst: IDispatch; var custom: PSafeArray);
var FApp:ExcelApplication;
CTP:TCustomTaskPane;
begin
...
  CTP:=TCustomTaskPane.Create(Self);
//?
  CTP.Visible:=True;
end;

using XE7,office2010.pas,excel2010.pas


Solution

  • Managed to do it myself. For anyone who have same issue, posting solution here

    • Create add-in
    • Add ActiveX form to add-in project
    • Add below code to addin .pas file
    procedure TmyAddin.CTPFactoryAvailable(const CTPFactoryInst: ICTPFactory); safecall;
    Var 
        CTP: _CustomTaskPane;
    //  NP: TActiveXformClass;
    begin   
        CTP:= CTPFactoryInst.CreateCTP('<replace with add-in name>.<replace with activeXform name>', 'pane caption', EmptyParam);
    //  NP := TNavigationPane(ctp.ContentControl);
        CTP.Visible := true;
    end;