Category: ActiveX
Title: Check if Word, Excel, Access, Outlook, Powerpoint is running
Date added: 15.03.2006
Hits: 3390
uses
ComObj, ActiveX;
function IsObjectActive(ClassName: string): Boolean;
var
ClassID: TCLSID;
Unknown: IUnknown;
begin
try
ClassID := ProgIDToClassID(ClassName);
Result := GetActiveObject(ClassID, nil, Unknown) = S_OK;
except
Result := False;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if IsObjectActive('Word.Application')
then ShowMessage('Word
is running !');
if IsObjectActive('Excel.Application')
then ShowMessage('Excel
is running !');
if IsObjectActive('Outlook.Application')
then ShowMessage('Outlook
is running !');
if IsObjectActive('Access.Application')
then ShowMessage('Access
is running !');
if IsObjectActive('Powerpoint.Application')
then ShowMessage('Powerpoint
is running !');
end;