Home > database >  Run a Google Apps Script from another file within the same project
Run a Google Apps Script from another file within the same project

Time:06-01

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?

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

enter image description here

CodePudding user response:

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

  • Related