将自定义菜单添加到Google文档 [英] Add custom menu to a Google Document
本文介绍了将自定义菜单添加到Google文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在发现Google应用程序脚本,我非常喜欢它的潜力。
I'm discovering Google App Script and I'm very attracted by its potential.
我想通过添加自定义菜单来改进Google文档。
我发现了许多如何在电子表格中做到这一点,但没有文件。
I want to improve a Google Document by adding a custom menu. I found many how-to to make this in a spreadsheet but nothing for document.
我错过了什么?
推荐答案
From: 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();
}
这篇关于将自定义菜单添加到Google文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文