Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2002, 05:09 AM
Martin_Dimitrov Martin_Dimitrov is offline
Senior Member
 
Join Date: Oct 2001
Posts: 150
Default MS Office Version

How Can I detect the MS Office version? Thanks ?!
Reply With Quote
  #2  
Old 05-08-2002, 05:30 AM
LörAn LörAn is offline
Senior Member
 
Join Date: Mar 2001
Posts: 1,506
Default RE: MS Office Version

What about getting this value in the registry :
HKEY_CLASSES_ROOT\Excel.Application\CurVer

(same with Word.Application, etc...)

LörAn.
MAIL: loran@superheros.as
ICQ : 112714184
Reply With Quote
  #3  
Old 05-08-2002, 05:37 AM
GoodFun GoodFun is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,645
Default RE: MS Office Version

read the registry at the key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office

if you find a key called 9.0 you have Office2000 installed, if it's 8.0, it's Office97.

you can use this code:

uses 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('\SOFTWARE\Microsoft\Office\8.0', False) then
begin
Result := 'Microsoft Office97;
end;
// check for Office2000
if Reg.OpenKey('\SOFTWARE\Microsoft\Office\9.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('\SOFTWARE\Microsoft\Office\10.0', False) then
begin
Result := 'Microsoft OfficeXP;
end;
finally
// make sure we free the object we created
Reg.Free;
end;
end;


Hope this helps,

Marcel

Please click on Accept if this helped...
Reply With Quote
  #4  
Old 07-08-2011, 09:55 AM
notidaho notidaho is offline
Member
 
Join Date: May 2011
Posts: 35
Default

Sorry to re-open thread, but I need this code to detect MS Office 2010. Is the registry key for this 11 or 12?

I ran the code on My OfficeXP machine told me it was indeed OfficeXP (key 10) but when I added a test for 11 and 12, it told me it was 11.

On my Office2010 trial machine, it seems to says key 12... am I safe to tell the program if key 13 is detected it's the new new version?

thanks
Reply With Quote
  #5  
Old 07-20-2011, 11:54 AM
notidaho notidaho is offline
Member
 
Join Date: May 2011
Posts: 35
Default

Another question if anyone's still reading - Will this function work on any version of Windows?

I've tried it on XP and 2000 but is the registry any different on NT, Vista, 7 etc?

Thanks
Reply With Quote
  #6  
Old 07-20-2011, 12:19 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,335
Default

Should work the same on those OS'es...
Reply With Quote
  #7  
Old 07-21-2011, 08:18 AM
join95278 join95278 is offline
Junior Member
 
Join Date: Jul 2011
Posts: 7
Default

I need this code to detect MS Office 2010

Reply With Quote
  #8  
Old 07-21-2011, 10:53 AM
notidaho notidaho is offline
Member
 
Join Date: May 2011
Posts: 35
Default

Some very helpful people at stackoverflow just told me that the above versions are actually incorrect

11- office2003
12- office 2007
13- N/A
14- office2010

and infact if you use Ole automation you can use Application.Version to obtain the version.

Here's the thread if anyone's interested...
http://stackoverflow.com/questions/6...omment-8022143
Reply With Quote
  #9  
Old 07-22-2011, 11:38 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,335
Default

First of all, there's a difference between incorrect and incomplete

And yes, with OLE automation this is also possible, but the only need for the office version information (if there is any, never needed to get the office version) is perhaps the early binding classes... And validating this by creating the objects is not the way to go then (works, but not a nice solution in my oppinion)... But when doing OLE I hope nowadays everybody does late binding anyways...
Reply With Quote
  #10  
Old 07-27-2011, 07:44 AM
kenvinlee89 kenvinlee89 is offline
Junior Member
 
Join Date: Jul 2011
Posts: 1
Default

Thanks you for the post.
Hi guys, Im a newbie. Nice to join this forum.


Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 06:44 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.