Mega Code Archive

 
Categories / Delphi / Examples
 

Determine the version of the word installation

Question: My Delphi application needs to verify that Microsoft Word is installed and it has to be at least Word version 2000. How can I do this? Answer: The function GetInstalledWordVersion creates a Word object and reads the version number from there. If creating the Word object fails, then Word is not (properly) installed, thus the function returns 0. // .. uses ComObj; const Wordnotinstalled = 0; Wordversion97 = 8; Wordversion2000 = 9; WordversionXP = 10; Wordversion2003 = 11; function GetInstalledWordVersion : integer; var Word: OLEvariant; begin { GetInstalledWordVersion } Result := 0; // Word is not installed try Word := CreateOLEObject('Word.Application'); Result := Word.version; Word.Quit; finally Word := Unassigned end; end; { GetInstalledWordVersion } begin //.. if GetInstalledWordVersion < Wordversion2000 then ShowMessage('You need a newer version of Word') //.. end.