How to Detect Installed Version of Ms-Office

How to detect installed version of MS-Office?

One way to check for the installed Office version would be to check the InstallRoot registry keys for the Office applications of interest.

For example, if you would like to check whether Word 2007 is installed you should check for the presence of the following Registry key:

HKLM\Software\Microsoft\Office\12.0\Word\InstallRoot::Path

This entry contains the path to the executable.

Replace 12.0 (for Office 2007) with the corresponding version number:


Office 97 - 7.0
Office 98 - 8.0
Office 2000 - 9.0
Office XP - 10.0
Office 2003 - 11.0
Office 2007 - 12.0
Office 2010 - 14.0 (sic!)
Office 2013 - 15.0
Office 2016 - 16.0
Office 2019 - 16.0 (sic!)

The other applications have similar keys:

HKLM\Software\Microsoft\Office\12.0\Excel\InstallRoot::Path
HKLM\Software\Microsoft\Office\12.0\PowerPoint\InstallRoot::Path

Or you can check the common root path of all applications:

HKLM\Software\Microsoft\Office\12.0\Common\InstallRoot::Path

Another option, without using specific Registry keys would be to query the MSI database using the MSIEnumProducts API as described here.

As an aside, parallel installations of different Office versions are not officially supported by Microsoft. They do somewhat work, but you might get undesired effects and inconsistencies.

Update: Office 2019 and Office 365

As of Office 2019, MSI-based setup are no longer available, Click-To-Run is the only way to deploy Office now. Together with this change towards the regularly updated Office 365, also the major/minor version numbers of Office are no longer updated (at least for the time being). That means that – even for Office 2019 – the value used in Registry keys and the value returned by Application.Version (e.g. in Word) still is 16.0.

For the time being, there is no documented way to distinguish the Office 2016 from Office 2019. A clue might be the file version of the winword.exe; however, this version is also incremented for patched Office 2016 versions (see the comment by @antonio below).

If you need to distinguish somehow between Office versions, e.g. to make sure that a certain feature is present or that a minimum version of Office is installed, probably the best way it to look at the file version of one of the main Office applications:

// Using the file path to winword.exe
// Retrieve the path e.g. from the InstallRoot Registry key
var fileVersionInfo = FileVersionInfo.GetVersionInfo(@"C:\Program Files (x86)\Microsoft Office\root\Office16\WINWORD.EXE");
var version = new Version(fileVersionInfo.FileVersion);

// On a running instance using the `Process` class
var process = Process.GetProcessesByName("winword").First();
string fileVersionInfo = process.MainModule.FileVersionInfo.FileVersion;
var version = Version(fileVersionInfo);

The file version of Office 2019 is 16.0.10730.20102, so if you see anything greater than that you are dealing with Office 2019 or a current Office 365 version.

How to detect installed version of MS Office within javascript?

this method worked for me in chrome, you may have to dumb-down the iteration for older copies of IE:

var has2013=([].slice.call(navigator.plugins)
.filter(function(a){return a.name.match("Microsoft Office")})[0].name||"")
.match(2013)||false;

alert(has2013);

How to detect Office 2019 programmatically?

From what we have found out the Office version numbers/build numbers can be the same for Office 2016, 2019 and Office 365.

Office 2016 and 2019 are supposed to have frozen feature sets while Office 365 will auto-update with new features. At some stage O365 and other build numbers will overlap. We found also that Office 2016 installed with Click-to-Run may have the same build number as 2019, although it is meant to contain security updates only.

Office 2016 installed with MSI will have a static build number. There's no MSI installer for Office 2019, meaning it will auto-update and its build numbers might increase the same way as the ones for Office 365?

In any case: it is no longer possible to determine the Office version from the build number. We have resorted to look up the following registry key in addition:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun 

If it doesn't exist and the major version number is 16 it is an Office 2016 MSI install.

If it exists, you know it's a Click-to-Run installation and you can examine the following subkey value from which you can infer 2016, 2019 or 365:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration\ProductReleaseIDs 

Example values are "O365ProPlusRetail" or "ProPlus2019Retail" or just "ProPlusRetail"

Any better suggestions welcome.

how to check MS office version installed on the machines

Search in (using the Registry class)

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths

or

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths

Version numbers are

  • 7.0 -97
  • 8.0 - 98
  • 9.0 -2000
  • 10.0 -2002
  • 11.0 -2003
  • 12.0 -2007
  • 14.0 -2010

Here is a c# implementation

Is there a way to get the Microsoft Office Version and it's License installed on the Computer?

Try it

System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo
{
WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal,
FileName = "cmd.exe",
RedirectStandardInput = true,
UseShellExecute = false,
Arguments = "/C reg query \"HKEY_CLASSES_ROOT\\Word.Application\\CurVer\""
};


procStartInfo.RedirectStandardOutput = true;
procStartInfo.RedirectStandardError = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
string output = proc.StandardOutput.ReadToEnd();

Console.WriteLine("Output: " + output);

string version = System.Text.RegularExpressions.Regex.Replace(output, "(.*)(Word\\.Application\\.)(\\d+)(.*)", "$3", System.Text.RegularExpressions.RegexOptions.Singleline);
Console.WriteLine("Office version: " + version);

Console.Read();

Office 97 - 7

Office 98 - 8

Office 2000 - 9

Office XP - 10

Office 2003 - 11

Office 2007 - 12

Office 2010 - 14

Office 2013 - 15

Office 2016 - 16

How to detect installed version of MS Office using javascript from IE?

Okey, so here is the answer (SharePoint works properly with both old and new Office clients without version detection, so there must be a solution)

try {
var g = new ActiveXObject("SharePoint.OpenDocuments.5");
alert('Office 2013 installed');
window.open('ms-word:ofe|u|http://server.com/12.docx');
}
catch (h) {
alert('Office 2010/older installed');
var g = new ActiveXObject("SharePoint.OpenDocuments");
g.EditDocument('http://server.com/12.docx');
}

The only problem left is document opening in 'Protected View' while SharePoint opens them in regular view.

Finding version of Microsoft Office installed on system at runtime in Visual Studio

First option, maintain two different .proj and .sln files (one for version 12 and one for 14).

Second and crazy kludge approach is as follows.

Add a dependant console application project to the solution, then add a post-build event to that project and make it run "always", in that post-build event execute the console application.

Within the console application include code to check if the highest version of Office that is installed and update the project .proj files as needed (only update if there is a change, don't update if no change).

First build will cause the project file to be changed and visual studio will prompt as it requires reloading, the second build will build perfectly fine.

This gets rid of the manual process but it still has to change the project file (which might cause havoc with your svn/git repo if you just commit all changes all the time).

Your other option is to try installing the office 14 primary interop assemblies and see if that lets you build without having version 14 installed.



Related Topics



Leave a reply



Submit