A computer can have multiples versions of Office.
But, you can discover if the machine has the Office 365 installed doing something like that:
using Microsoft.Win32;
...
private bool Has365Office()
{
RegistryView registryView = RegistryView.Registry32;
string registryKey = "Software\Microsoft\Office\16.0\Common\Licensing\LicensingNext";
using (RegistryKey key = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, registryView).OpenSubKey(registryKey))
{
foreach (string subkeyName in key.GetValueNames())
{
if (subkeyName.Contains("o365"))
return true;
}
}
return false;
}
...
To know what version is running, or at least will run when the user opens it, you can do something like that:
using Microsoft.Office.Interop;
...
public string GetOfficeVersion()
{
string sVersion = string.Empty;
Microsoft.Office.Interop.Word.Application appVersion = new Microsoft.Office.Interop.Word.Application();
appVersion.Visible = false;
switch (appVersion.Version.ToString())
{
case "7.0":
sVersion = "95";
break;
case "8.0":
sVersion = "97";
break;
case "9.0":
sVersion = "2000";
break;
case "10.0":
sVersion = "2002";
break;
case "11.0":
sVersion = "2003";
break;
case "12.0":
sVersion = "2007";
break;
case "14.0":
sVersion = "2010";
break;
case "16.0":
sVersion = "2016 or 2019 or 365";
break;
default:
sVersion = "Too Old!";
break;
}
return sVersion;
}
You can combine the code above to get what you need. I hope it helps!
both codes were made from this answer: link