Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How add action button to google-doc?

I want to add button or another widget with click action to my Google Document with Apps Scripts;
How will i can do it?

function addButton()
{
  var body = DocumentApp.getActiveDocument().getBody();
  // code for add button to body.
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Create a menu

function onOpen() {
   menu();
}

function menu() {
  DocumentApp.getUi().createMenu('MyMenu')
  .addItem('Function Descript', 'functionName')
  .addToUi();  
}

function functionName() {
  //a function that does nothing
}

Your best bet is to learn how to do this on your own so that you don’t have to return here everytime you require a modification.

If you wish to add buttons I would recommend placing them on a sidebar with html. That will take a little more effort but in the long run it will be worth learning how to build and reuse the html file.

Reference:

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading