简体   繁体   English

MS Office - 隐藏ContentControls

[英]MS Office - Hiding ContentControls

How would you hide a ContentControl when data is filled using a 3. party UI= 当使用3. party UI =填充数据时,您将如何隐藏ContentControl?

Could be (simple example): 可能是(简单的例子):

_ _

CC1 - Name: John Doe CC1 - 姓名:John Doe

CC2 - Phone: 555 1233 4321 CC2 - 电话:555 1233 4321

CC3 - Title: CTO CC3 - 标题: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. 当使用书签插入名称,手机和标题时,使用隐藏字符时很容易将第二行设置为隐藏programaticcaly。

_ _

CC1- Name: John Doe CC1-姓名:John Doe

CC3- Title: CTO CC3-标题:CTO

__ __

When using ContentControls this is not possible because ContentControls cannot be hidden using formatting. 使用ContentControls时,这是不可能的,因为无法使用格式隐藏ContentControls。 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? 如何仅使用ContentControls完成上述示例?

We are looking to use this for an Office.js app as well - using bookmarks is not an option. 我们也希望将它用于Office.js应用程序 - 使用书签不是一种选择。

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. 胡安。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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