简体   繁体   中英

MS Office - Hiding ContentControls

How would you hide a ContentControl when data is filled using a 3. party UI=

Could be (simple example):

_

CC1 - Name: John Doe

CC2 - Phone: 555 1233 4321

CC3 - Title: CTO

_

When using a bookmark to insert Name, Phone and Title it is easy to set the second line to be hidden programaticcaly when using hidden characters.

_

CC1- Name: John Doe

CC3- Title: CTO

__

When using ContentControls this is not possible because ContentControls cannot be hidden using formatting. Grouping the data in one Content Control is not an option as the document management tools that we integrate with does not support this.

How to accomplish the above mentioned example using only ContentControls?

We are looking to use this for an Office.js app as well - using bookmarks is not an option.

Hello you have a couple of alternatives.

  1. Make the content control appearance to be hidden after the insertion. Check out this sample code:

  function insertHideenContentControlInSelection() { Word.run(function (context) { var myCC = context.document.getSelection().insertContentControl(); myCC.appearance = "hidden"; // you can also set it to 'boundingBox' or 'tags' return context.sync(); }) } 

  1. Not sure if this will work for your scenario but there is a property of content controls that they are removed after editing:

  function insertContentControlWithProperties() { Word.run(function (context) { var myCC = context.document.getSelection().insertContentControl(); myCC.removeWhenEdited = true; return context.sync(); }) } 

Hope this helps. thanks! Juan.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM