Author: Jonas Bilinkevicius
In the application I am writing I need to get data from an Excel spreadsheet and
then insert it into a database. I am going to automate Excel. What I would like to
know is how I can detect to see if excel is installed, and if it is, what version
of Excel is on the user's computer. How can I do this?
Answer:
1 { ... }2 var3 ClassID: TCLSID;
4 strOLEObject: string;
5 begin6 strOLEObject := 'Excel.Application';
7 if (CLSIDFromProgID(PWideChar(WideString(strOLEObject)), ClassID) = S_OK) then8 begin9 {application is installed}10 end11 else12 begin13 {application is not installed}14 end15 end;
16 17 //To get the version, just read Version property of Excel.Application:18 19 xls := CreateOLEObject('Excel.Application');
20 v := xls.Version;