Add custom menu to a Google Document

纵然是瞬间 提交于 2019-12-13 03:02:08

问题


I'm discovering Google App Script and I'm very attracted by its potential.

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.

Did I miss anything ?


回答1:


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();
 }



回答2:


It is not possible to have a Document as a container for a script and therefore not possible to add a menu item to the Document.

There is an open issue on the issue tracker which you can subscribe to.



来源:https://stackoverflow.com/questions/11357808/add-custom-menu-to-a-google-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!