'How to detect Windows 10 and Office 365 versions in Word JS Add-In

Our Word Add-In (using Office-js), which is still work in progress isn't compatible with IE11. We aren't sure we would like to support that either, certainly not if we don't have to.

According to the compatibility matrix Browsers used by Office Add-ins if Windows 10 ver. >= 1903 and Microsoft 365 ver. >= 16.0.13127.20082 then "Microsoft Edge with original WebView (EdgeHTML)" will be used. We have our dev/testing environments (Mac/Windows) setup up that way and our add-in works there without a problem.

However, we realised that some users can also load our add-in outside of this version boundary and our add-in doesn't load/work properly when they do.

So I am wondering if there is a way to detect Win+Office version from within Add-In (on load):

  1. Detect the target Windows and 365 versions (if possible) and show an "incompatible" message to user?
  2. Specify in manifest the required minimum versions (apart from the Office-JS API version) and prevent the add-in from loading/installing?
  3. Any other alternative?

Thanks a lot in advance for some guidance.



Solution 1:[1]

I am not sure about windows 10 build number, but can provide a way to get word host full version on desktop platform.

Generally, following solution will work,

const context = window.external.GetContext()
context.GetHostFullVersion()

But in some of the cases, where add-in opens in iframe, it needs accessed by following way,

const context = parent.window.external.GetContext()
context.GetHostFullVersion()

I have tried this on windows platform, this will provide you version string like "16.0.13328.20292".

Solution 2:[2]

To get the app version within an Office.js addin, you can also use "Office.context.diagnostics.version". You can also get the platform with "Office.context.diagnostics.platform".

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Gullbyrd