outlook commandbarbutton要怎麼設定onaction這個屬性? |
答題得分者是:william
|
kaija
一般會員 發表:16 回覆:14 積分:6 註冊:2003-07-24 發送簡訊給我 |
小弟我透過api的方式呼叫outlook出來
並在outlook裏面新增一個commandbar & commandbarbutton
可是我並沒有辦法寫入一個event
我希望使用者在按下button後能去執行一段程式
但是沒有辦法
看msdn還有office附的vbaolxx.chm都說是使用onaction的方法去設定事件
另外小弟是透過ap的方式去呼叫outlook 有辦法能寫入事件到button裏面嗎?
以下附上一小段的程式碼 myCommandBarButton := myCommandBar.Controls.Add;
myCommandBarButton.Style := 1;
myCommandBarButton.Visible := true;
myCommandBarButton.OnAction := 'go'; go這個procedure只去執行一個動作…就是ShowMessage
我試過在OnAction裏面代入go() 或go();
都沒有效果 希望高手不吝指教
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
Want to create COM addin? FYI,
http://www.delphi32.co.yu/preuzeti_tekstovi/delphi_in_the_office.htm
|
kaija
一般會員 發表:16 回覆:14 積分:6 註冊:2003-07-24 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
Is the procedure go a VBA procedure or Delphi one? Since this is a Delphi board and your code is in object pascal, I assume this procedure is written in Delphi and you can't do it like myCommandBarButton.OnAction := 'go'.... Office knows nothing about 'go'....
|
kaija
一般會員 發表:16 回覆:14 積分:6 註冊:2003-07-24 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
引言: yes…那個procedure是用delphi寫的 (可以用vb寫嗎?如果可以的話要怎麼做@@?我是知道delphi可以插入一段組合語言,但是不知道怎麼插入一段vb code) 這也是我的問題所在 我一直很想介紹outlook來認識一下go這位朋友 可是不得其門而入 希望william版大能再給予指教 @@~ 謝謝~~The only possible way I can think of is: Follow the article, create a button server and connect to your commandbar button... then set the OnClick.... |
kaija
一般會員 發表:16 回覆:14 積分:6 註冊:2003-07-24 發送簡訊給我 |
|
kaija
一般會員 發表:16 回覆:14 積分:6 註冊:2003-07-24 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
unit BtnSvr; interface uses OleServer, ActiveX, Office2000, Classes, Variants; type TBtnClickProc = procedure (const Ctrl: OleVariant; var CancelDefault: OleVariant) of object; TButtonServer = class(TOleServer) private FIntf : _CommandBarButton; FOnClick : TBtnClickProc; function GetStyle: msoButtonStyle; procedure SetStyle(const Value: msoButtonStyle); function GetTag: String; procedure SetTag(const Value: String); function GetShortcutText: String; procedure SetShortCutText(const Value: String); function GetHint: string; procedure SetHint(const Value: string); function GetBeginGroup: boolean; procedure SetBeginGroup(const Value: boolean); protected procedure InitServerData; override; procedure InvokeEvent(DispID: TDispID; var Params: TVariantArray); override; function GetCaption : String; procedure SetCaption(Value : String); function GetVisible : boolean; procedure SetVisible(const Value: boolean); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Connect; override; procedure ConnectTo(svrIntf: _CommandBarButton); procedure Disconnect; override; procedure Delete; // remove from owner command bar procedure PasteFace; procedure CopyFace; property Caption : String read GetCaption write SetCaption; property Visible : boolean read GetVisible write SetVisible; property Style : msoButtonStyle read GetStyle write SetStyle; property BeginGroup: boolean read GetBeginGroup write SetBeginGroup; property Tag : String read GetTag write SetTag; property ShortCutText : String read GetShortcutText write SetShortCutText; property Hint: string read GetHint write SetHint; property OnClick : TBtnClickProc read FOnClick write FOnClick; end; // TButtonServer implementation { TButtonServer } procedure TButtonServer.Connect; var punk: IUnknown; begin if FIntf = nil then begin punk := GetServer; ConnectEvents(punk); FIntf:= punk as _CommandBarButton; end; end; procedure TButtonServer.ConnectTo(svrIntf: _CommandBarButton); begin Disconnect; FIntf := svrIntf; ConnectEvents(FIntf); end; procedure TButtonServer.CopyFace; begin FIntf.CopyFace; end; constructor TButtonServer.Create(AOwner: TComponent); begin inherited Create(AOwner); end; procedure TButtonServer.Delete; begin FIntf.Delete(EmptyParam); end; destructor TButtonServer.Destroy; begin inherited Destroy; end; procedure TButtonServer.Disconnect; begin if Fintf <> nil then begin DisconnectEvents(FIntf); FIntf := nil; end; end; function TButtonServer.GetBeginGroup: boolean; begin Result := FIntf.BeginGroup; end; function TButtonServer.GetCaption: String; begin Result := FIntf.Caption; end; function TButtonServer.GetHint: string; begin Result := FIntf.TooltipText; end; function TButtonServer.GetShortcutText: String; begin Result := FIntf.ShortcutText; end; function TButtonServer.GetStyle: msoButtonStyle; begin Result := FIntf.Style; end; function TButtonServer.GetTag: String; begin Result := FIntf.Tag; end; function TButtonServer.GetVisible: boolean; begin Result := FIntf.Visible; end; procedure TButtonServer.InitServerData; const CServerData: TServerData = ( ClassID: '{55F88891-7708-11D1-ACEB-006008961DA5}'; // '{000209FF-0000-0000-C000-000000000046}'; IntfIID: '{000C030E-0000-0000-C000-000000000046}'; // '{00020970-0000-0000-C000-000000000046}'; EventIID: '{000C0351-0000-0000-C000-000000000046}'; // '{000209FE-0000-0000-C000-000000000046}'; LicenseKey: nil; Version: 500 ); begin ServerData := @CServerData; end; procedure TButtonServer.InvokeEvent(DispID: TDispID; var Params: TVariantArray); begin case DispID of -1: exit; // DISPID_UNKNOWN 1: if Assigned(FOnClick) then FOnClick(Params[0], Params[1]); end; end; procedure TButtonServer.PasteFace; begin FIntf.PasteFace; end; procedure TButtonServer.SetBeginGroup(const Value: boolean); begin FIntf.Set_BeginGroup(Value); end; procedure TButtonServer.SetCaption(Value: String); begin FIntf.Set_Caption(Value); end; procedure TButtonServer.SetHint(const Value: string); begin FIntF.Set_TooltipText(Value); end; procedure TButtonServer.SetShortCutText(const Value: String); begin FIntF.Set_ShortcutText(Value); end; procedure TButtonServer.SetStyle(const Value: msoButtonStyle); begin FIntF.Set_Style(Value); end; procedure TButtonServer.SetTag(const Value: String); begin FIntF.Set_Tag(Value); end; procedure TButtonServer.SetVisible(const Value: boolean); begin FIntf.Set_Visible(Value); end; end. |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |