DelphiFAQ Home Search:

Determine the version of the Word installation

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

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.

Comments:

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Washington, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
Leave your comment here:
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.