Is there official clipboard access from office-js for Word add-in?

Viewed 60

I have reviewed the office-js docs and not found any formal way of working with the clipboard through a Word add-in.

I attempted to use the newer navigator.clipboard.writeText but it is automatically rejected by the internal Word browser (where the add-in is hosted) without prompting the user (like a browser does). I have not seen any associated support for permissions policy that can be used to communicate with Word that the add-in would like clipboard permissions.

So, I am resorting to the deprecated document.executeCommand('copy') for now, but am concerned that will get my add-in rejected by the MS App Store.

Is there an official/sanctioned way to use the clipboard from within a MS Word add-in?

2 Answers

OfficeJS doesn't provide anything for that. You may sill use the Document.execCommand() API which includes "copy", "cut" and "paste". But it was deprecated and may not work in the web browsers any longer.

Feature requests on Tech Community are considered, when the dev team go through the planning process. Use the github label: Type: product feature request at https://aka.ms/M365dev-suggestions .

It seems like there's one method Range.copyFrom of Excel rich client api. I can't find the alternatives either. Maybe you can ask to provide the new feature. Whether it could be in the future feature list or not may also take some time.

Related