Skip to main content
Commonmark migration
Source Link

If you want to add something to a menu, you need to implement an onOpen function, and do the necessary menu setup there.

Take a look at this example from [Google's documentation][1]Google's documentation:

function onOpen() {
  // Add a custom menu to the spreadsheet.
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Custom Menu')
      .addItem('First item', 'menuItem1')
      .addToUi();
}

This will add a menu Custom Menu with a single item First item, which, when selected, will launch a function menuItem1, which you will have to implement:

function menuItem1() {
  // Do whatever you like here
}

Note that you will have to reload your file ( spreadsheet, document, form or presentation ) in order to have onOpen run. So you won't see any effect by just writing the script and clicking save, you need to reload (Cmd-R) on the file window for the new menu to appear.

A script error may prevent the menu from appearing. If you don't see the desired result after reloading the file, check the script editor's View → Execution Transcript for any errors. [1]: https://developers.google.com/apps-script/guides/triggers/#onopen

If you want to add something to a menu, you need to implement an onOpen function, and do the necessary menu setup there.

Take a look at this example from [Google's documentation][1]:

function onOpen() {
  // Add a custom menu to the spreadsheet.
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Custom Menu')
      .addItem('First item', 'menuItem1')
      .addToUi();
}

This will add a menu Custom Menu with a single item First item, which, when selected, will launch a function menuItem1, which you will have to implement:

function menuItem1() {
  // Do whatever you like here
}

Note that you will have to reload your file ( spreadsheet, document, form or presentation ) in order to have onOpen run. So you won't see any effect by just writing the script and clicking save, you need to reload (Cmd-R) on the file window for the new menu to appear.

A script error may prevent the menu from appearing. If you don't see the desired result after reloading the file, check the script editor's View → Execution Transcript for any errors. [1]: https://developers.google.com/apps-script/guides/triggers/#onopen

If you want to add something to a menu, you need to implement an onOpen function, and do the necessary menu setup there.

Take a look at this example from Google's documentation:

function onOpen() {
  // Add a custom menu to the spreadsheet.
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Custom Menu')
      .addItem('First item', 'menuItem1')
      .addToUi();
}

This will add a menu Custom Menu with a single item First item, which, when selected, will launch a function menuItem1, which you will have to implement:

function menuItem1() {
  // Do whatever you like here
}

Note that you will have to reload your file ( spreadsheet, document, form or presentation ) in order to have onOpen run. So you won't see any effect by just writing the script and clicking save, you need to reload (Cmd-R) on the file window for the new menu to appear.

A script error may prevent the menu from appearing. If you don't see the desired result after reloading the file, check the script editor's View → Execution Transcript for any errors.

extending the scope of the answer as the same works for spreadsheets, documents, forms and presentations of the G Suite document editors.
Source Link

If you want to add something to a menu, you need to implement an onOpen function, and do the necessary menu setup there.

Take a look at this example from [Google's documentation][1]:

function onOpen() {
  // Add a custom menu to the spreadsheet.
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Custom Menu')
      .addItem('First item', 'menuItem1')
      .addToUi();
}

This will add a menu Custom Menu with a single item First item, which, when selected, will launch a function menuItem1, which you will have to implement:

function menuItem1() {
  // Do whatever you like here
}

Note that you will have to reload your file ( spreadsheet, document, form or presentation ) in order to have onOpen run. So you won't see any effect by just writing the script and clicking save, you need to reload (Cmd-R) on the spreadsheetfile window for the new menu to appear.

A script error may prevent the menu from appearing. If you don't see the desired result after reloading the spreadsheetfile, check the script editor's View → Execution Transcript for any errors. [1]: https://developers.google.com/apps-script/guides/triggers/#onopen

If you want to add something to a menu, you need to implement an onOpen function, and do the necessary menu setup there.

Take a look at this example from [Google's documentation][1]:

function onOpen() {
  // Add a custom menu to the spreadsheet.
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Custom Menu')
      .addItem('First item', 'menuItem1')
      .addToUi();
}

This will add a menu Custom Menu with a single item First item, which, when selected, will launch a function menuItem1, which you will have to implement:

function menuItem1() {
  // Do whatever you like here
}

Note that you will have to reload your spreadsheet in order to have onOpen run. So you won't see any effect by just writing the script and clicking save, you need to reload (Cmd-R) on the spreadsheet window for the new menu to appear.

A script error may prevent the menu from appearing. If you don't see the desired result after reloading the spreadsheet, check the script editor's View → Execution Transcript for any errors. [1]: https://developers.google.com/apps-script/guides/triggers/#onopen

If you want to add something to a menu, you need to implement an onOpen function, and do the necessary menu setup there.

Take a look at this example from [Google's documentation][1]:

function onOpen() {
  // Add a custom menu to the spreadsheet.
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Custom Menu')
      .addItem('First item', 'menuItem1')
      .addToUi();
}

This will add a menu Custom Menu with a single item First item, which, when selected, will launch a function menuItem1, which you will have to implement:

function menuItem1() {
  // Do whatever you like here
}

Note that you will have to reload your file ( spreadsheet, document, form or presentation ) in order to have onOpen run. So you won't see any effect by just writing the script and clicking save, you need to reload (Cmd-R) on the file window for the new menu to appear.

A script error may prevent the menu from appearing. If you don't see the desired result after reloading the file, check the script editor's View → Execution Transcript for any errors. [1]: https://developers.google.com/apps-script/guides/triggers/#onopen

added 32 characters in body
Source Link
Vidar S. Ramdal
  • 17.4k
  • 11
  • 71
  • 82

If you want to add something to a menu, you need to implement an onOpen function, and do the necessary menu setup there.

Take a look at this example from [Google's documentation][1]:

function onOpen() {
  // Add a custom menu to the spreadsheet.
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Custom Menu')
      .addItem('First item', 'menuItem1')
      .addToUi();
}

This will add a menu Custom Menu with a single item First item, which, when selected, will launch a function menuItem1, which you will have to implement:

function menuItem1() {
  // Do whatever you like here
}

Note that you will have to reload your spreadsheet in order to have onOpen run. So you won't see any effect by just writing the script and clicking save, you need to reload (Cmd-R) on the spreadsheet window for the new menu to appear.

A script error may prevent the menu from appearing. If you don't see the desired result after reloading the spreadsheet, check the script editor's View → Execution Transcript for any errors. [1]: https://developers.google.com/apps-script/guides/triggers/#onopen

If you want to add something to a menu, you need to implement an onOpen function, and do the necessary menu setup there.

Take a look at this example from [Google's documentation][1]:

function onOpen() {
  // Add a custom menu to the spreadsheet.
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Custom Menu')
      .addItem('First item', 'menuItem1')
      .addToUi();
}

This will add a menu Custom Menu with a single item First item, which, when selected, will launch a function menuItem1, which you will have to implement:

function menuItem1() {
  // Do whatever you like here
}

Note that you will have to reload your spreadsheet in order to have onOpen run. So you won't see any effect by just writing the script and clicking save, you need to reload (Cmd-R) on the spreadsheet window for the new menu to appear.

A script error may prevent the menu from appearing. If you don't see the desired result, check the script editor's View → Execution Transcript for any errors. [1]: https://developers.google.com/apps-script/guides/triggers/#onopen

If you want to add something to a menu, you need to implement an onOpen function, and do the necessary menu setup there.

Take a look at this example from [Google's documentation][1]:

function onOpen() {
  // Add a custom menu to the spreadsheet.
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Custom Menu')
      .addItem('First item', 'menuItem1')
      .addToUi();
}

This will add a menu Custom Menu with a single item First item, which, when selected, will launch a function menuItem1, which you will have to implement:

function menuItem1() {
  // Do whatever you like here
}

Note that you will have to reload your spreadsheet in order to have onOpen run. So you won't see any effect by just writing the script and clicking save, you need to reload (Cmd-R) on the spreadsheet window for the new menu to appear.

A script error may prevent the menu from appearing. If you don't see the desired result after reloading the spreadsheet, check the script editor's View → Execution Transcript for any errors. [1]: https://developers.google.com/apps-script/guides/triggers/#onopen

Source Link
Vidar S. Ramdal
  • 17.4k
  • 11
  • 71
  • 82
Loading