2005. április 27., szerda

Detect if Excel is installed


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?


{ ... }
  ClassID: TCLSID;
  strOLEObject: string;
  strOLEObject := 'Excel.Application';
  if (CLSIDFromProgID(PWideChar(WideString(strOLEObject)), ClassID) = S_OK) then
    {application is installed}
    {application is not installed}

To get the version, just read Version property of Excel.Application:

xls := CreateOLEObject('Excel.Application');
v := xls.Version;

Nincsenek megjegyzések:

Megjegyzés küldése