![]() ![]() Screenshots - Attached the screenshot of the error. ![]() Once issue is reproduced, it would not be reproduced again until we re-start Word Application and follow the above repro steps again.īecause of this issue it disables us to delete the content control in the inserted table in cell programtically.Import the code in the script lab and test from. Now, after deletion of the content control and text in it, you would observe that the Error "A table in this document has become corrupted".Now, click on the button "deletecontentcontrol" in the same snippet in Word scriptLab Add-in.Place the cursor in the inserted table and click on the button "insertcontentcontrol" in Word scriptlab add-in having imported gist (link provided above) from github.Add one table in new Word document (one cell is enough) in environment having Word 2016 MSI version.I am able to repro the issue in-house independent of any custom/moving parts. When trying to delete the content control in the table. While executing the below code in client machine having Office 365 (monthly channel and latest build) however, in Office 2016 MSI when the same code is executed creates an error (Error Source: Microsoft Word) Expected BehaviorĮrror as above is not expected, it should delete the content control and text in Word 2016 MSI without issue. 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.Developing an Office JS Word add-in and trying to add and delete the content controls (and text in it) in the table inserted in Word document in enviroment Office 2016 MSI only, error is produced: "A table in this document has become corrupted". 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. In the document that is hosted in the Visual Studio designer, select the content control that you want to protect. LockContentControl: Returns or sets a Boolean that represents whether the user can delete a content control from the active document. In the Properties window, set one or both of the following properties: Returns the level of the content controlwhether the content control surrounds text, paragraphs, table cells, or table rows or if it is inline. To prevent users from editing the control, set LockContents to True. 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. RichTextContentControl editableControl Private. How do I show all content controls as 'None' simultaneously. 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. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |