I just added this function which determines which mailmerge method to use. It seems to work on XP and Windows 2000. Is there any reason why it wouldn t work on NT, Vista, 7 and other Windows versions? I m thinking will there be an issue with the registry?
function GetMSOfficeVersion: String;
var Reg: TRegistry;
begin
Result := Office Version Not Found ;
// create the registry object
Reg := TRegistry.Create;
try
// set the root key
Reg.RootKey := HKEY_LOCAL_MACHINE;
// check for Office97
if Reg.OpenKey( SOFTWAREMicrosoftOffice8.0 , False) then
begin
Result := Microsoft Office97 ;
end;
// check for Office2000
if Reg.OpenKey( SOFTWAREMicrosoftOffice9.0 , False) then
begin
Result := Microsoft Office2000 ;
end;
// check for OfficeXP -- not sure if this is correct
// you have to verify the key on a machine with OfficeXP
if Reg.OpenKey( SOFTWAREMicrosoftOffice10.0 , False) then
begin
Result := Microsoft OfficeXP(regkey10) ;
end;
// check for 11.0
if Reg.OpenKey( SOFTWAREMicrosoftOffice11.0 , False) then
begin
Result := Microsoft OfficeXP(regkey11) ;
end;
// check for 12
if Reg.OpenKey( SOFTWAREMicrosoftOffice12.0 , False) then
begin
Result := Microsoft Office2010 ;
end;
finally
// make sure we free the object we created
Reg.Free;
end;
end;