1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| strOLEObject := 'Excel.Application';
if (CLSIDFromProgID(PWideChar(WideString(strOLEObject)), ClassID) <> S_OK)
then
begin
MessageBox(0,PChar('Microsoft Excel n''est pas installé.'),'ExcelApplication',MB_ICONEXCLAMATION);
exit;
end;
lcid := LOCALE_USER_DEFAULT;
Result := GetActiveObject(CLASS_Application_, nil, Unknown);
if (Result = MK_E_UNAVAILABLE) then // Excel est ouvert
XlApp := CoApplication_.Create
else // Excel n'est pas ouvert
begin
OleCheck(Result);
OleCheck(Unknown.QueryInterface(_Application, XlApp));
end; |