I need to test if I can use Excel OLE from my program since it can be launched on PCs without Excel. Code samples on the net assume Excel is installed, but what if not?
XLApp := CreateOleObject('Excel.Application');
try
// Hide Excel
XLApp.Visible := False;
// Open the Workbook
XLApp.Workbooks.Open(aPath);
...snip...
finally
// Quit Excel
if not VarIsEmpty(XLApp) then
begin
XLApp.Quit;
XLAPP := Unassigned;
end;
end;
Would that be correct code to find if Excel is installed?
//Try to create Excel OLE
try
XLApp := CreateOleObject('Excel.Application');
except
ShowMessage('Error opening Excel');
Exit;
end;