Is there a way to use the same google-app-script in multiple different workbooks?

断了今生、忘了曾经 提交于 2020-08-20 11:19:16

问题


I have created 20+ Goolge Sheets workbooks. I have also written scripting to run each one. The one thing I would love to do is instead of have 20+ codes to run in each one, I would like to have 1 code that was used throughout each of my workbooks.

Does anyone have any insite on how to make this happpen?

I have tried using the library function. I am not sure if I am doing it correctly though.

**//This is my Menu//**

function onOpen() {

var submenu = [{name: "Submit Order", functionName: "SubmitOrder"},
{name: "Recommended Order", functionName: "myRecommendations"},{name: "Clear Entire Form", functionName: "ClearAllCells"},
  {name: "Clear Product Information", functionName: "ClearProductCells"},{name: "Notifications", functionName: "showSidebar"}];
  SpreadsheetApp.getActiveSpreadsheet().addMenu('OTSR Tools', submenu); 

  }

function showSidebar() {
  var html = HtmlService.createHtmlOutputFromFile('Page')
      .setTitle('Notifications')
      .setWidth(500);
  SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
      .showSidebar(html);

   }

**//This is the HTML for my Sidebar//**

Hello everyone,<br>
Your quote of the week is...<br>
<br>
<i>"Our greatest weakness lies in giving up. <br>
The most certain way to succeed is always to try just one more time."</i><br>
<br>
Thomas A. Edison<br>
<br>
If there are any updates they will be found below.<br>
<br>
This is a Test!!!!!!!!!<br>
<br>
Thank you,<br>
<br>
Jason Mattson<br>
Back-End Support"<br> 
<br>
<input type="button" value="Close" onclick="google.script.host.close()" />

回答1:


Yes, there is. Publish is as G Suite Editor add-on. For details please read https://developers.google.com/gsuite/add-ons/overview

Related

  • Google Apps script publishing addon for internal use
  • Publish an add-on privately


来源:https://stackoverflow.com/questions/55497262/is-there-a-way-to-use-the-same-google-app-script-in-multiple-different-workbooks

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