简体   繁体   English

从同一项目中的另一个文件运行 Google Apps 脚本

[英]Run a Google Apps Script from another file within the same project

I would like to run the script "xGen_FilterRemove" from my "Generic Macros.gs" file in my "Test" Script located in "Macro.gs" as per below, but am know sure how to correctly reference it?我想从位于“Macro.gs”中的“测试”脚本中的“通用 Macros.gs”文件中运行脚本“xGen_FilterRemove”,如下所示,但我知道如何正确引用它?

function Test() {
  
    var aCurrentBook = SpreadsheetApp.getActive();
    'Generic Macros.gs'.xGen_FilterRemove()
      }
    };

在此处输入图像描述

Just run it like this像这样运行它

function Test() {
  var aCurrentBook = SpreadsheetApp.getActive();
  xGen_FilterRemove()
}

All of the functions in a project are accessible universally no matter what file they are in. That's why all functions must have a unique name.项目中的所有函数都可以通用访问,无论它们位于什么文件中。这就是为什么所有函数都必须具有唯一名称的原因。 The files are provided to make it easier to organize them.提供这些文件是为了更容易组织它们。 You can have as many functions in a file as you wish您可以在一个文件中拥有任意数量的函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM