有没有办法在多个不同的工作簿中使用相同的google-app-script?

时间:2019-04-03 14:12:57

标签: google-apps-script google-sheets google-apps-script-addon

我创建了20多个Goolge Sheets工作簿。我还编写了脚本来运行每个脚本。我想做的一件事是,而不是每个代码中都要运行20多个代码,我希望每个工作簿中都使用1个代码。

有人在现场制作这种玩具吗?

我尝试使用库函数。我不确定我是否做得正确。

**//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 个答案:

答案 0 :(得分:0)

是的,有。发布是G Suite编辑器的附加组件。有关详细信息,请阅读https://developers.google.com/gsuite/add-ons/overview

相关