我在发现Google应用脚本,并且很受其潜力所吸引。将自定义菜单添加到Google文档
我想通过添加自定义菜单来改进Google文档。 我发现了许多如何在电子表格中进行此操作,但没有任何文档。
我错过了什么吗?
我在发现Google应用脚本,并且很受其潜力所吸引。将自定义菜单添加到Google文档
我想通过添加自定义菜单来改进Google文档。 我发现了许多如何在电子表格中进行此操作,但没有任何文档。
我错过了什么吗?
来源:https://developers.google.com/apps-script/reference/document/document-app#getActiveDocument()
// Add a custom menu to the active document, including a separator and a sub-menu.
function onOpen() {
DocumentApp.getUi()
.createMenu('My Menu')
.addItem('My Menu Item', 'myFunction')
.addSeparator()
.addSubMenu(DocumentApp.getUi().createMenu('My Submenu')
.addItem('One Submenu Item', 'mySecondFunction')
.addItem('Another Submenu Item', 'myThirdFunction'))
.addToUi();
}
不可能将Document作为脚本的容器,因此无法将菜单项添加到Document中。
有一个open issue on the issue tracker你可以订阅。
我希望能够选择的内容直接发送到Twitter。你有想法来管理这个吗? 感谢您的帮助。 – 2012-07-06 08:06:52
@ user1506051:这篇[文章](https://developers.google.com/apps-script/articles/twitter_tutorial)将帮助您从GAS开始使用Twitter。 – megabyte1024 2012-07-06 08:25:25
这个答案已经过时。 – 2017-10-18 02:50:27