COM Add-in for Office 2000

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
bussoftwareAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ptmcompCommented:
The documentation is available from Microsoft: Office 2000 SDK. You had to buy it.
Sorry don't know what's written inside...
ptm.
0
florisbCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
florisbCommented:
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
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

bussoftwareAuthor Commented:
Thanks. Could you please tell me the site of the article?
0
florisbCommented:
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
intheCommented:
hi floris im small bit interested in this stuff also .
what delphi magazine are we talking here?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.