Reputation: 342
I'm developing a VSTO Add-in and I have an issue. I got the Office version number from the registry but the number is 16.0, and I know Office 2016, 2019, and 365 share the same version number.
How to distinguish the three Office versions? I'm using C# but would appreciate any way of solving this question.
_officeVersions.Add("7.0", "Office97");
_officeVersions.Add("8.0", "Office98");
_officeVersions.Add("9.0", "Office2000");
_officeVersions.Add("10.0", "OfficeXP");
_officeVersions.Add("11.0", "Office2003");
_officeVersions.Add("12.0", "Office2007");
_officeVersions.Add("14.0", "Office2010");
_officeVersions.Add("15.0", "Office2013");
_officeVersions.Add("16.0", "Office2016");
Upvotes: 1
Views: 1080
Reputation: 1186
I'm not sure of your exact context, but if you can get the Process
object corresponding to the Office process you are running inside, you can look it up from the main module's file info. Here's some sample code which assumes your add-in is for Excel:
var process = Process.GetProcessesByName("excel").Single();
var version = process.MainModule.FileVersionInfo.FileVersion;
version
now contains a string which can be looked up for Office 2016/2019 or separately for Office 365.
Upvotes: 0
Reputation: 49395
That's where the bits like build numbers after 16.0
play a vital role.
You can use the Update history for Office 2016 C2R and Office 2019 and Update history for Microsoft 365 Apps (listed by date) for identifying the exact Office version.
Upvotes: 1