0

I have found this fantastic script to convert a document to a PDF and automatically save it to a users Drive account, however I'd now like to deploy a button on the toolbar for all of our users that will allow them to run this script at the click of a button.

Is this possible? If so, how is it done?

Community
  • 1
  • 1
KMJO
  • 85
  • 1
  • 3
  • 13

2 Answers2

1

You can create new Menu on the toolbar with following code. When user clicks the menu item, your script (convertPDF function) will be executed. You can refer this documentation for more details.

function onOpen() {
  var menuEntries = [
    {name: 'Export PDF', functionName: 'convertPDF'},
  ];
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  ss.addMenu('PDF', menuEntries);
}
Purushotham
  • 3,770
  • 29
  • 41
0

With Spreadsheet.getUi object you can add new options in the menu. Check this documentation that explains this process and how to associate your functions to the items in the menu.

In the example is also used the Trigger "OnOpen". Which will run the functionality that adds the new menu items every time the file is opened.

Gerardo
  • 3,460
  • 1
  • 16
  • 18