

The following code example demonstrates using the LockContents and LockContentControl properties of two different RichTextContentControl objects in a document-level project. Set the LockContents property of the content control to true to prevent users from editing the control, and set the LockContentControl property to true to prevent users from deleting the control. To prevent users from deleting the control, set LockContentControl to True. To prevent users from editing the control, set LockContents to True. In the Properties window, set one or both of the following properties: In the document that is hosted in the Visual Studio designer, select the content control that you want to protect. To protect a content control at design time

For more information, see How to: Add content controls to Word documents. You can also protect content controls that you add to a document at run time by using a VSTO Add-in project. You can prevent users from editing or deleting a content control by setting properties of the control in a document-level project at design time or at run time. For more information, see Features available by Office application and project type. You can protect a part of a document that is not in a content control.Īpplies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Word. There are several ways you can protect parts of a Microsoft Office Word document by using content controls: When you protect part of a document, you prevent users from changing or deleting the content in that part of the document. Applies to: Visual Studio Visual Studio for Mac Visual Studio Code
