Implement Document.Protect and Document.Unprotect in Word JavaScript API

Implement Document.Protect and Document.Unprotect in Word JavaScript API
2

Upvotes

Upvote

 Feb 23 2024
3 Comments (3 New)
New

I'm developing an add-in using the Word JavaScript API, and I need the ability to work with protected Word documents programmatically. In VBA and VSTO, I was able to unprotect these documents, alter them, and then protect them again. Please implement the Document.Protect method (Word) | Microsoft Learn and Document.Unprotect method (Word) | Microsoft Learn methods in Word's JavaScript API so that I don't have to do this through VBA or VSTO. It looks like this was already done in Excel (see ExcelScript.WorksheetProtection interface - Office Scripts | Microsoft Learn).

Comments
Copper Contributor

This seems like a very basic function that is needed and is missing. Microsoft, please read this and take action.

Microsoft

@frank-hoffman Thanks for submitting this requirement. Can you let me know your use case here?

Copper Contributor

Sure @Yun_Wang. The use case we have here is that we're dealing with a legal document that has protected content sections. The reason for this is so customers don't inadvertently alter other parts of the document that are used in downstream processing. The customers want to have the ability to remove one of the content controls from the document but can't unless we unprotect the document first. In the legacy system there was some VBA that would do this for them. I've seen some other parts of the code that also needed to unprotect the document for other reasons, though I haven't tracked down all the use cases there yet.