Looking for a way to create a custom menu on Google Apps Script available across ALL my Google Docs, not just the one for which I created the script. The function itself works properly, it is the setup/trigger rather that is giving me trouble. Not sure if this is possible, given I'm seeing info saying Custom Menus must be bound to a particular document (rather than the whole object), so open to other suggestions too - the goal is to be able to apply a specific template to a Google Doc when I'd like (they will always be created in the same folder).
function OnOpen(e) {
DocumentApp.getUi().createMenu('Template Options')
.addItem('Apply Customer Note Template', 'menuItem1')
.addToUi()
}
function menuItem1() {
var body = DocumentApp.getActiveDocument().getBody();
var OppTitle = body.appendParagraph("Opportunity Name");
OppTitle.setHeading(DocumentApp.ParagraphHeading.TITLE);
OppTitle.setAlignment(DocumentApp.HorizontalAlignment.CENTER);
...
DocumentApp.getUi().alert('Customer Template applied.');
}
Yes, you can do that, it is called Editor Addons. Just think about all the apps that exist in the Marketplace, they also create the app or function once, then package it for the Google Marketplace where any number of users can install the package and use it across all Spreadsheets.