Link to home
Start Free TrialLog in
Avatar of ljee
ljeeFlag for Romania

asked on

Automation, Word - Assigning OnQuit programatically?

Hi,

The code below fails:

procedure TSomeObject.Quitting(Sender: TObject);
begin
  messagebeep(0);
end;

procedure TSomeObject.SomeProcedure;
var
  FApplication: Variant;
begin
  try
    FApplication := GetActiveOleObject( 'Word.Application );
  except
    FApplication := CreateOleObject( 'Word.Application' );
  end;

  FApplication.OnQuit := Quitting;
  // the above line fails with compiler error 'Not enough parameters'.


  ..........
end;

Actually my goal is to have my application receive a notification when Word is closed. Is that possible? How?
Avatar of ljee
ljee
Flag of Romania image

ASKER

Acceptable solution only through automation, I don't want hacks like: monitoring processes, system-wide application hooks.

thx
ASKER CERTIFIED SOLUTION
Avatar of Scay7
Scay7
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ljee

ASKER

Thanks Scay7. You got the points, your second alternative with IsObjectActive works fine for me.

This question can be closed (frankly it's a long time since I did not visited EE, I don't rememeber what am I supposed to do now??).

regards,

ljee
here we go a nice picture of how to accept the answer :P

https://www.experts-exchange.com/help.jsp#hi68

Peace Scay7
Avatar of ljee

ASKER

geee, thanks :-)