Monday, October 20, 2008

How to Get Office Version Programmatically

one of my friend asked me this question: how to get Microsoft Word's version installed on client system?
a few searches and here is the answer so far :
1- use this VBS code [^]:
Set objWord = CreateObject("Word.Application")
Wscript.Echo "Version: " & objWord.Version
Wscript.Echo "Build: " & objWord.Build

2- find the Word application path and check the file version (C#) [^] :
read the registry key in "Software\Microsoft\Windows\CurrentVersion\App Paths" to find winword.exe key, and then in the key find Path's value that refer to exe file of Word app.
//looks inside CURRENT_USER:
RegistryKey _mainKey = Registry.CurrentUser;
_mainKey = _mainKey.OpenSubKey(
"Software\Microsoft\Windows\CurrentVersion\App Paths\\"
+ "winword.exe", false);
if (_mainKey == null)
//looks inside LOCAL_MACHINE:
_mainKey = Registry.LocalMachine;
_mainKey = _mainKey.OpenSubKey(
"Software\Microsoft\Windows\CurrentVersion\App Paths\\"
+ "winword.exe", false);
if (_mainKey == null)
throw new Exception("it does not exist!");


See the reference for complete code

3- use Microsoft.Office name space in .Net [^]

just this code :

//be aware of exceptions
new Microsoft.Office.Interop.Word.Application().Version);

1 comment:

Anonymous said...

[url=]Mulberry Bayswater[/url] As the summer season comes to an end, consider purchasing next year's summer clothing for the baby. [url=]Canada Goose tilbud[/url] Hrqhsmgho [url=]louboutin uk[/url]
yfcaad 263851 943573 [url=]dr dre[/url]