Adding arguments to a function in the onOpen entries object

后端 未结 1 1579
挽巷
挽巷 2020-12-05 21:50

Is there are a way I can add arguments to a function that will be added to the Script Center Menu on a Google Spreadsheet document? This is the normal onOpen method.

相关标签:
1条回答
  • 2020-12-05 22:20

    I don't think that is possible exactly as you have written, but you can do it in the following way:

    function onOpen() {
      var sheet = SpreadsheetApp.getActiveSpreadsheet();
      var entries = [{
        name : "Summary",
        functionName : "myParameterisedOpen",
      }
      ];
      sheet.addMenu("Script Center Menu", entries);
    };
    
    function myParameterisedOpen() {
      myOnOpen("Some value");
    };
    
    0 讨论(0)
提交回复
热议问题