如何使用office js API取消选择单词中的选择

时间:2017-02-03 12:09:39

标签: ms-word office-js

我已经构建了一个依赖用户进行某些选择的应用程序,然后应用程序会做出相应的反应。

但是我想在应用完成工作后取消选择所选文本。

我无法在API中看到允许我取消选择当前选择的选项。

这不可能吗?

1 个答案:

答案 0 :(得分:4)

您可以使用select()方法并传入override func viewWillAppear(_ animated: Bool) { ... myResults = myParentObject.children.sorted(byKeyPath: "childPath", ascending: true) ... rowHeights = Array(repeating: nil, count: myParentObject.children.count) ... } 'start'作为参数。这将导致取消选择文本并将光标放在对象的开头或结尾。

取消选择当前选择,您可以使用以下内容:

'end'

请注意,您可以针对rangeparagraph或整个body执行此操作,以便 Word.run(function (context) { var range = context.document.getSelection(); range.select('start'); return context.sync(); }) 将光标放在文档的开头{ {1}}会将其放在当前段落的开头。