![remove content control microsoft word remove content control microsoft word](https://i.ytimg.com/vi/mhQGjLdjipw/maxresdefault.jpg)
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. 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. 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.įor more information, see Features available by Office application and project type. You can also protect content controls that you add to a document at run time by using a VSTO Add-in project. To protect a content control at design time For more information, see How to: Add content controls to Word documents.
![remove content control microsoft word remove content control microsoft word](https://i.ytimg.com/vi/BQP3EiRfibk/maxresdefault.jpg)
![remove content control microsoft word remove content control microsoft word](http://addbalance.com/word/images/2019DocumentProperties.png)
In the document that is hosted in the Visual Studio designer, select the content control that you want to protect. In the Properties window, set one or both of the following properties: How do I show all content controls as 'None' simultaneously. To prevent users from editing the control, set LockContents to True. I have some text that is 'content control' and some that is not, and I cannot integrate the 2 together. To prevent users from deleting the control, set LockContentControl to True. 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. The following code example demonstrates using the LockContents and LockContentControl properties of two different RichTextContentControl objects in a document-level project. RichTextContentControl deletableControl To run this code, add the code to the ThisDocument class in your project, and call the AddProtectedContentControls method from the ThisDocument_Startup event handler. Step 3: Press Ctrl + S to save the changes. This will remove restrict editing from the Word document. When an Unprotect Document dialog pops up, type your password correctly and click OK. The same is true of Italics or (I think) Underlining. Step 2: Click the Stop Protection button at the bottom of the Restrict Editing pane. RichTextContentControl editableControl Private. Thus, if you create your Content Control using text which has Bold as an underlying format and switch it off, when you copy, you are copying the bold toggle switch into an area which does not already have Bold turned on. RichTextContentControl Word.Range range1 = ĭeletableControl = (range1,ĭeletableControl.PlaceholderText = "You can delete this control, " + Private void AddProtectedContentControls() Private. RichTextContentControlĭim editableControl As. Private Sub AddProtectedContentControls() Word.Range range2 = ĮditableControl = (range2,ĮditableControl.PlaceholderText = "You can edit this control, " +ĮditableControl.LockContentControl = true ĭim deletableControl As. Sections(1).Footers(wdHeaderFooterPrimary).Range.ContentControls LockContents = Falseįor Each ccDefinition In. Sections(1).Headers(wdHeaderFooterPrimary).Range.ContentControls You might have to get a little more complicated if any CCs are in text boxes, frames or other odd locations. For Each CC In ActiveDocument.ContentControls. There are potentially many different headers and footers, so I believe this only works for basic ones: For Each ccDefinition In. This is probably all you need: Sub ClearCCs() Dim CC As ContentControl. If you have controls in your header/footer, you can add this after the "Next" to loop through headers or footers. For Each CC In ActiveDocument.StoryRanges (wdTextFrameStory).ContentControls. I know this is a necromance, but I had the same problem and couldn't find the answer, so I just did it myself and here it is. You can basically adjust everything in this way, just put a watch on ccDefinition and look at what you can adjust while stepping through the code.