How to link script to an image google script

2019-09-19 13:54发布

问题:

I add with google script a row in a spreadsheet and then I insert an image in a cell of this row. I want to know if it's possible to link this image to a script's function ?

回答1:

Insert > image > in top right menu of image, Assign Script. It's much better practice to create a menu option for a sidebar Add-on to appear that allows users to click actual buttons and not images.



回答2:

How to create an app script:

  1. Go to the option TOOLS --> SCRIPT EDITOR
  2. FILE --> NEW --> SCRIPT FILE --> (Enter the nae of the file (with/without file extension (.gs)))
  3. Example file name --> test.gs
  4. Create a function / Use the existing function and write your app script
  5. Example function onClickImage { ........ }

How to add images + assign app script to run from the Spreadsheet:

  1. Go to the option INSERT --> IMAGE.
  2. Choose any of the options to upload the image into the spreadsheet.
  3. Click the image and select the option (:) available at top-right-corner of the image.
  4. Select the ASSIGN SCRIPT option
  5. Add the created function name onClickImage (not the script name test.gs)
  6. Now whenever you click the image, the respective assigned app script function will be triggered accordingly.