?
Solved

COM Add-in for Office 2000

Posted on 1999-12-04
6
Medium Priority
?
236 Views
Last Modified: 2010-04-04
Is it possible to write a COM Add-in for Office 2000 with D5 in an easy way (as it is possible with VB6)? If yes, which steps are necessary? Is there any documentation available?

Thanks for help.

Olaf
0
Comment
Question by:bussoftware
6 Comments
 
LVL 10

Expert Comment

by:ptmcomp
ID: 2259130
The documentation is available from Microsoft: Office 2000 SDK. You had to buy it.
Sorry don't know what's written inside...
ptm.
0
 
LVL 2

Accepted Solution

by:
florisb earned 800 total points
ID: 2261734
Delphi Magazine septemer issue has an article about this, with source. I include some source here. Perhaps you can download the whole demo from the Delphi Magazine pages. Contact me otherwise.

I 'played' with this method... ...and found it very complicated...;-(

Good Luck,
Floris.

unit Main;

interface

uses
  Windows, ComObj, ActiveX, SteveAddIn_TLB, AddInDesignerObjects_TLB,
  EventSink;

type
  TOfficeHostApp = (ohaOutlook); //in original demo : ohaWord, ohaExcel, et cetera.
  TOfficeHostApps = set of TOfficeHostApp;

  TSteveAddIn = class(TAutoObject, ISteveAddIn, IDTExtensibility2)
  private
    FApplication: OleVariant;
    FEventSink: TEventSink;
    FHostApp: TOfficeHostApp;
  protected
    { IDTExtensibility2 methods }
    procedure OnConnection(const Application_: IDispatch;
      ConnectMode: ext_ConnectMode; const AddInInst: IDispatch;
      var custom: PSafeArray); safecall;
    procedure OnDisconnection(RemoveMode: ext_DisconnectMode;
      var custom: PSafeArray); safecall;
    procedure OnAddInsUpdate(var custom: PSafeArray); safecall;
    procedure OnStartupComplete(var custom: PSafeArray); safecall;
    procedure OnBeginShutdown(var custom: PSafeArray); safecall;
  public
    property Application: OleVariant read FApplication;
    property HostApp: TOfficeHostApp read FHostApp;
  end;

  TOfficeAddInFactory = class(TAutoObjectFactory)
  private
    FFriendlyName: string;
    FLoadBehavior: Integer;
    FSupportedApps: TOfficeHostApps;
  protected
  public
    constructor Create(ComServer: TComServerObject; AutoClass: TAutoClass;
      const ClassID: TGUID; Instancing: TClassInstancing;
      ThreadingModel: TThreadingModel; SupportedApps: TOfficeHostApps;
      const FriendlyName: string; LoadBehavior: Integer);
  end;

implementation

uses SysUtils, ComServ, Dialogs, Registry,outlook_tlb,
  Classes;

procedure TSteveAddIn.OnAddInsUpdate(var custom: PSafeArray);
begin
showMessage('UH');
end;

procedure TSteveAddIn.OnBeginShutdown(var custom: PSafeArray);
begin
showMessage('pre shutdown');
end;


procedure TSteveAddIn.OnConnection(const Application_: IDispatch;
  ConnectMode: ext_ConnectMode; const AddInInst: IDispatch;
  var custom: PSafeArray);
var
  Unk: IUnknown;
begin
showMessage('Add-in will now get connected.');
if Application_.QueryInterface(Outlook_TLB._Application, Unk) = S_OK then
  begin
  FHostApp := ohaOutlook;
  end
else
  begin
  MessageDlg('UMS COM Add-in used for other application than Outlook', mtError, [mbOk], 0);
  ///????
  exit;
  end;
FApplication := Application_;
//if connected during startup... ...not.
if (ConnectMode <> ext_cm_Startup) then
  OnStartupComplete(custom);
end;



procedure TSteveAddIn.OnDisconnection(RemoveMode: ext_DisconnectMode;
  var custom: PSafeArray);
begin
showMessage('Outlook disconnected');
  if (RemoveMode <> ext_dm_HostShutdown) then OnBeginShutdown(custom);
  FEventSink.Free;
  FApplication := Unassigned;
end;


procedure TSteveAddIn.OnStartupComplete(var custom: PSafeArray);
begin
showMessage('Floris: Outlook startup completed');
end;

{ TOfficeAddInFactory }
constructor TOfficeAddInFactory.Create(ComServer: TComServerObject;
  AutoClass: TAutoClass; const ClassID: TGUID;
  Instancing: TClassInstancing; ThreadingModel: TThreadingModel;
  SupportedApps: TOfficeHostApps; const FriendlyName: string;
  LoadBehavior: Integer);
begin
  inherited Create(ComServer, AutoClass, ClassID, Instancing, ThreadingModel);
//not before startup.
  FSupportedApps := SupportedApps;
  FFriendlyName := FriendlyName;
  FLoadBehavior := LoadBehavior;
end;



initialization
  TOfficeAddInFactory.Create(ComServer, TSteveAddIn, Class_SteveAddIn_,
    ciMultiInstance, tmApartment, [ohaOutlook], 'UMS Service Add-in', 3);
end.



0
 
LVL 2

Expert Comment

by:florisb
ID: 2261754
I mean: as far as I know; there's no easy way to create such an add-in.

But changing the code of a working demo is some kind of easy way... ...I managed to get a working add-in for my purposes, without understanding all the source... ....yet.
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 

Author Comment

by:bussoftware
ID: 2261890
Thanks. Could you please tell me the site of the article?
0
 
LVL 2

Expert Comment

by:florisb
ID: 2261944
the article isn't on the site of the Delphi Magazine.

Please mail me at florisb@euronet.nl, then I'll send you a copy.

Floris.
0
 
LVL 17

Expert Comment

by:inthe
ID: 2316110
hi floris im small bit interested in this stuff also .
what delphi magazine are we talking here?
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…
Suggested Courses

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question