An Office service that supports add-ins to interact with objects in Office client applications.
Range.insertComment is part of the WordApi 1.4 requirement set and is supported on Word on the web, but Word on the web also has additional, online‑only behavior and preview APIs that are surfaced through the WordApiOnline and preview requirement sets.
Key points from the platform behavior and docs:
-
Range.insertCommentitself- The method is documented on
Word.Rangewith[API set: WordApi 1.4]and is therefore included in the numbered requirement set. - Word on the web supports WordApi 1.4, which is why
Office.context.requirements.isSetSupported('WordApi', '1.4')correctly returnstrue. - The
NotAllowederror is not a signal that the API is unknown; it indicates that the host (Word in a browser) is blocking the specific action in the current environment or configuration.
- The method is documented on
- Online‑only and preview behavior
- Word on the web has a special
WordApiOnlinerequirement set that contains features only available online. This set is a superset of the latest numbered requirement set and is considered production only for Word on the web. - Preview APIs and eventing around comments (for example,
onCommentAdded,onCommentChanged,onCommentSelected,onCommentDeselectedonWord.Range) are explicitly marked as preview only and must not be used in production. These are surfaced under the WordApi BETA requirement set and can behave differently or be restricted.
- Word on the web has a special
- Why
isSetSupported('WordApi', '1.4')can betruebut the call still fails-
isSetSupportedonly tells that the host recognizes and exposes the API set; it does not guarantee that every call will be allowed in every scenario. - Word on the web can still reject a particular operation at runtime with
NotAllowedif the action is not permitted in that context (for example, due to current document mode, feature rollout state, or internal restrictions in the browser host). - The error payload shown (
code: "NotAllowed",errorLocation: "Range.insertComment", message saying the action is not supported by Word in a browser) is the expected way the host reports such a runtime restriction.
-
- Recommended handling pattern
- Keep using
Office.context.requirements.isSetSupported('WordApi', '1.4')to gate use ofinsertCommentat a high level. - Additionally, handle
NotAllowedfromRange.insertCommentexplicitly and fall back to an alternative behavior (or disable the feature) when running onOffice.context.platform === 'OfficeOnline'. - Do not rely on preview comment events (
onCommentAdded,onCommentChanged,onCommentSelected,onCommentDeselected) in production, as they are marked as WordApi BETA and may change or be unavailable.
- Keep using
In summary, the behavior observed is consistent with the platform: Word on the web advertises support for WordApi 1.4, but may still block Range.insertComment in some environments with NotAllowed. The add‑in should both check the requirement set and be prepared to catch and handle NotAllowed at runtime when running in a browser.
References: