DelphiFAQ Home Search:
General :: Programming :: Delphi
General Delphi related information.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

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.

Generated 8:02:06 on Feb 24, 2018