突出显示文档中的绑定 [英] Highlight bindings in a document

查看:61
本文介绍了突出显示文档中的绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Office 1.1的JavaScript API的Office加载项.我正在尝试突出显示Word文档中的绑定以及Excel文档中与单元格的绑定,以便用户可以轻松识别它们.

I have an Office Add-in using JavaScript API for Office 1.1. I am trying to highlight bindings in a Word document and bindings to cells in Excel documents so the user can easily recognize them.

我看到API允许使用setFormatsAsync格式化TableBindings,但是我的是Matrix和Text.我不使用Table类型,因为它添加了标题行,而总行弄乱了我的逻辑.

I see the API allows formatting of TableBindings using setFormatsAsync but mine are Matrix and Text. I don't use Table type because it adds a header row and the total row messes up my logic.

是否可以格式化或突出显示绑定?

Is there a way to format or highlight the bindings?

我希望它是临时的-类似于当您将鼠标悬停在绑定上方时背景颜色会稍微改变的方式,但是我可以为文本加上颜色然后删除颜色.

I will prefer this to be temporary - similar to the way the background color changes a bit when you hover on top of the binding but I can live with coloring the text and then removing the color.

推荐答案

您在这里有几个选择.要使用格式突出显示,请使用 RangeFormat 对象修改轮廓,背景或其他属性.这是背景填充的代码:

You have several options here. To highlighting with formatting, use the RangeFormat object to modify the outline, background, or other properties. Here's the code for a background fill:

Excel.run(function (ctx) { 
    var myRange = ctx.workbook.bindings.getItem("myBinding").getRange();
    myRange.format.fill.color = "FFFF00";
    return ctx.sync(); 
});

或者,您可以通过使用户的选择移至绑定位置来吸引用户的注意:

Alternatively, you can draw the user's attention by causing their selection to move to the binding:

Excel.run(function (ctx) { 
    var myRange = ctx.workbook.bindings.getItem("myBinding").getRange();
    myRange.select();
    return ctx.sync(); 
});

最后,如果您也希望上面的代码也能在Excel 2013中工作,则可以使用以下代码段完成相同的操作:

Finally, if you want the code above to work in Excel 2013 too, you can accomplish the same thing with this snippet:

var myDoc = Office.context.document;
myDoc.goToByIdAsync("myBinding", Office.GoToType.Binding, function (asyncResult) {});

-Michael Saunders,Office加载项的程序经理

-Michael Saunders, program manager for Office add-ins

这篇关于突出显示文档中的绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆