VSTO加载项和任务窗格应用程序(JS/HTML)之间的双向通信 [英] Two-way communication between VSTO add-in and a Task Pane app (JS/HTML)

查看:109
本文介绍了VSTO加载项和任务窗格应用程序(JS/HTML)之间的双向通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在台式机Office应用程序中运行时,是否可以使VSTO加载项和基于JS/HTML的Task Pane应用程序相互通信?

Is it possible to have a VSTO add-in and a JS/HTML based Task Pane app talk to each other when running inside desktop Office application?

目标是使用VSTO桥接x平台Office API中尚不存在(或永远不会存在)的功能.

The goal would be to bridge capabilities not yet present (or never will be present) in the x-platform Office APIs using VSTO.

推荐答案

正如Evgene所说,没有开箱即用的功能(尽管该主题已经在内部讨论中提到了,所以我会非常想知道您的情况,特别是您如何处理VSTO(台式机专用)情况.

As Evgene mentioned, there is no out-of-the-box functionality for this (though the topic has certainly come up in internal discussions, so I would be very curious to hear your scenario, and particularly how you would handle the VSTO-only-on-the-desktop case).

如果您现在想尝试一下,可能仍然可以使用一些创造性的解决方案.假设您有一个隐藏的工作表,上面有一个命名范围,用作VSTO和Taskpane应用程序之间的通信缓冲区.

If you wanted to try this now, you probably still could with a bit of a creative solution. Imagine you have a hidden sheet with a named range on it, which you use as a communication buffer between VSTO and your taskpane app.

对于VSTO => JS通信:让任务窗格在指定的范围内创建绑定,然后使用binding-data-changed事件来侦听来自VSTO加载项的传入消息.

For VSTO => JS communication: have the taskpane create a binding over the named range, then use the binding-data-changed event to listen to an incoming message from your VSTO add-in.

对于JS => VSTO通信:让JS将数据设置为绑定(如上所述,该数据是在指定范围内创建的).在VSTO端,侦听数据更改事件,将传入范围与指定范围的范围相交,如果相交不为null,则获取文本以获取传入消息.

For JS => VSTO communication: have the JS set data to the binding (which, as above, was created over the named range). On the VSTO side, listen to data changed event, intersect the incoming range with the named range's range, and if the intersection is not null, fetch the text to get the incoming message.

如果您最终尝试了这种方法,请务必将线程的运行情况保持在最新状态-我很想听到这个消息.

If you do end up trying out this approach, do keep the thread posted on how it went -- I'd be quite curious to hear.

〜Michael Zlatkovsky(Office可扩展性团队的开发人员)

~ Michael Zlatkovsky (developer on Office Extensibility team)

这篇关于VSTO加载项和任务窗格应用程序(JS/HTML)之间的双向通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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