Schau vorher nach ob Eine Office-Anwendung, in Deinem Fall Word geöffnet ist.
Delphi-Quellcode:
function IsOfficeProgActive(sClassName:
String): Boolean;
//Aufrufbeispiel
{procedure TForm1.Button1Click(Sender: TObject);
begin
if IsOfficeProgActive('Word.Application') then
ShowMessage('Word läuft');
if IsOfficeProgActive('Excel.Application') then
ShowMessage('Excel läuft');
if IsOfficeProgActive('Outlook.Application') then
ShowMessage('Outlook läuft');
if IsOfficeProgActive('Access.Application') then
ShowMessage('Access läuft');
if IsOfficeProgActive('Powerpoint.Application') then
ShowMessage('Powerpoint läuft');
end;}
var
ClassID: TCLSID;
Unknown: IUnknown;
begin
try
ClassID := ProgIDToClassID(sClassName);
Result := GetActiveObject(ClassID,
nil, Unknown) = S_OK;
except
Result := False;
end;
end;