Cứ upload lên ai cần thì họ dùng, họ cảm ơn. Còn đây thì chỉ thấy Úp - Mở thôi.
Vào trang
http://techvanguards.com/ của Bác BinhLy
https://github.com/jhc-systems/DelphiUIAutomation
https://www.davidghoyle.co.uk/WordPress/?p=311
Hình như bằng ngôn ngữ lập trình Pascal thì phải, thấy họ viết như thế lày:
unit ExcelApp.MenuButton.pas;
interface
uses Office2000_TLB, ExcelApp.EventSink;
type
TMenuButton = class(TObject)
private
FID: string;
FButton: _CommandBarButton;
FSink: TEventSink;
FCookie: Integer;
FClickProc: TClickProc;
public
constructor Create(const Parent: CommandBarPopup; const strID: string; const strCaption:
string; const EventHandler: TClickProc; const MenuOptions: TMenuOptions); overload;
constructor Create(const Parent: CommandBar; const strCaption: string; const EventHandler:
TClickProc; const MenuOptions: TMenuOptions); overload;
destructor Destroy; override;
property Button: _CommandBarButton read FButton;
property ID: string read FID default 0;
property ClickProc: TClickProc read FClickProc;
end;
implementation
{ TMenuButton }
constructor TMenuButton.Create(const Parent: CommandBarPopup; const strID: string; const
strCaption: string; const EventHandler: TClickProc; const MenuOptions: TMenuOptions);
begin
end;
constructor TMenuButton.Create(const Parent: CommandBar; const strCaption: string; const
EventHandler: TClickProc; const MenuOptions: TMenuOptions);
begin
end;
destructor TMenuButton.Destroy;
begin
end;
end.
------------------------------------------------------------
View attachment 295814
unit Unit2;
interface
uses
Windows, ActiveX, ComObj, Variants;
const
CLASS_DTExtensibility2: TGUID = '{AD1C5BA3-0140-4E45-8C92-2550B1271BC0}';
type
IDTExtensibility2 = interface(IDispatch)
['{B65AD801-ABAF-11D0-BB8B-00A0C90F2744}']
procedure OnConnection(const HostApp: IDispatch; ext_ConnectMode: Integer;
const AddInInst: IDispatch; var custom: PSafeArray); safecall;
procedure OnDisconnection(ext_DisconnectMode: Integer; var custom: PSafeArray); safecall;
procedure OnAddInsUpdate(var custom: PSafeArray); safecall;
procedure OnStartupComplete(var custom: PSafeArray); safecall;
procedure BeginShutdown(var custom: PSafeArray); safecall;
procedure DoAction(const Control: IUnknown); safecall;
function DoLoadImage(const aImageName: WideString): IPictureDisp; safecall;
end;
IRibbonExtensibility = interface(IDispatch)
['{000C0396-0000-0000-C000-000000000046}']
function GetCustomUI(const RibbonID: WideString): WideString; safecall;
end;
TOfficeAddInsTest = class(TAutoObject, IDTExtensibility2, IRibbonExtensibility)
private
protected
procedure BeginShutdown(var custom: PSafeArray); safecall;
function GetCustomUI(const RibbonID: WideString): WideString; safecall;
procedure OnAddInsUpdate(var custom: PSafeArray); safecall;
procedure OnConnection(const HostApp: IDispatch;
ext_ConnectMode: Integer; const AddInInst: IDispatch;
var custom: PSafeArray); safecall;
procedure OnDisconnection(ext_DisconnectMode: Integer;
var custom: PSafeArray); safecall;
procedure OnStartupComplete(var custom: PSafeArray); safecall;
procedure DoAction(const Button: IUnknown); safecall;
function DoLoadImage(const aImageName: WideString): IPictureDisp; safecall;
end;
implementation
uses
AxCtrls, Graphics, ComServ;
procedure TOfficeAddInsTest.OnConnection(const HostApp: IDispatch;
ext_ConnectMode: Integer; const AddInInst: IDispatch;
var custom: PSafeArray);
begin
end;
procedure TOfficeAddInsTest.OnDisconnection(ext_DisconnectMode: Integer;
var custom: PSafeArray);
begin
end;
procedure TOfficeAddInsTest.BeginShutdown(var custom: PSafeArray);
begin
end;
procedure TOfficeAddInsTest.OnAddInsUpdate(var custom: PSafeArray);
begin
end;
procedure TOfficeAddInsTest.OnStartupComplete(var custom: PSafeArray);
begin
end;
procedure TOfficeAddInsTest.DoAction(const Button: IUnknown);
begin
MessageBox(0, 'Hello, World', 'Information', MB_ICONINFORMATION)
end;
function TOfficeAddInsTest.DoLoadImage(const aImageName: WideString): IPictureDisp;
var
PictureDesc: TPictDesc;
begin
if aImageName = 'mainicon.ico' then begin
with PictureDesc do begin
cbSizeOfStruct := SizeOf(PictureDesc);
picType := PICTYPE_ICON;
hIcon := LoadIcon(HInstance, 'MAINICON')
end;
OleCheck(OleCreatePictureIndirect(PictureDesc, IPicture, True, Result))
end else
Result := nil
end;
function TOfficeAddInsTest.GetCustomUI(const RibbonID: WideString): WideString; safecall;
begin
Result :=
'<customUI xmlns="
http://schemas.microsoft.com/office/2006/01/customui" loadImage="DoLoadImage">'#13#10+
' <ribbon>'#13#10+
' <officeMenu>'#13#10+
' <menu idMso="FileSendMenu">'#13#10+
// ' <button id="TestButtonID" insertAfterMso="FileSendAsAttachment" label="Hello, World!" imageMso ="HappyFace" onAction="DoAction"/>'#13#10+
' <button id="TestButtonID" insertAfterMso="FileSendAsAttachment" label="Hello, World!" image="mainicon.ico" onAction="DoAction"/>'#13#10+
' </menu>'#13#10+
' </officeMenu>'#13#10+
' </ribbon>'#13#10+
'</customUI>'
end;
initialization
TAutoObjectFactory.Create(ComServer, TOfficeAddInsTest, CLASS_DTExtensibility2, ciSingleInstance);
end.