Office JS API PowerPoint插入链接 [英] Office JS API PowerPoint insert link

查看:75
本文介绍了Office JS API PowerPoint插入链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Office JS API将超链接插入PowerPoint幻灯片。

我们怎么做?

I need to insert a hyperLink to PowerPoint slide using Office JS API.
How we can do it?

推荐答案

Hello Mikhail,

Hello Mikhail,

这可能不是很明显,但是当你使用PowerPoint幻灯片内容时,你实际上使用的是"Office.context.document"。宾语。您可能会发现以下资源非常有用:

读取和写入文档或电子表格中活动选择的数据

It's may not be obvious, but when you work with PowerPoint slides content, you actually work with "Office.context.document" object. You may find useful the following resource: Read and write data to the active selection in a document or spreadsheet

资源中提供的示例使用"Office.CoercionType.Text"。要设置您想要使用的超链接"Office.CoercionType.Html",

Document.setSelectedDataAsync方法
。你的代码示例可能看起来像......

The examples provided in the resource work with "Office.CoercionType.Text". To set the hyperlink you would want to use "Office.CoercionType.Html" in Document.setSelectedDataAsync method. The example of your code may look like ...

function writeHtmlData() {
    Office.context.document.setSelectedDataAsync("<a href='https://my.website.com'>Go to my website!</a>", {coercionType: Office.CoercionType.Html}, function (asyncResult) {
        if (asyncResult.status === Office.AsyncResultStatus.Failed) {
            // work with errors: asyncResult.error.message
        }
    });
}


这篇关于Office JS API PowerPoint插入链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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