MenuBar and MenuItem

This example will show you how to create Horizontal and vertical Menu Bar and add Items to these menu bar.


Demo screenShots:

Example Code:

function doGet(e) {

  var app = UiApp.createApplication();


  //Create menu bar

  //var menuBar = app.createMenuBar(true);// For vertical menuBar

  var menuBar = app.createMenuBar();//For horizontal menubar


  //Create a handler.. you can create separate handler for each menuItem

  var handler = app.createServerHandler();


  //top level menu items

  var menuItem0 = app.createMenuItem('MenuItem0', handler);

  var menuItem1 = app.createMenuItem('MenuItem1', handler);

  var menuItem2 = app.createMenuItem('MenuItem2', handler);

  var menuItem3 = app.createMenuItem('MenuItem3', handler);


  //create menuItem separators

  var separator0 = app.createMenuItemSeparator();

  var separator1 = app.createMenuItemSeparator();

  var separator2 = app.createMenuItemSeparator();

  var separator3 = app.createMenuItemSeparator();

  var separator4 = app.createMenuItemSeparator();


  //Add the menu item separators and menuItem to the MenuBar







  return app;




Horizontal Menu Bar, Vertical Menu Bar, Menu bar using apps script, Google Apps Script Menu Bar