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:
- Go to the option TOOLS --> SCRIPT EDITOR
- FILE --> NEW --> SCRIPT FILE --> (Enter the nae of the file (with/without file extension (.gs)))
- Example file name --> test.gs
- Create a function / Use the existing function and write your app script
- Example function onClickImage { ........ }
How to add images + assign app script to run from the Spreadsheet:
- Go to the option INSERT --> IMAGE.
- Choose any of the options to upload the image into the spreadsheet.
- Click the image and select the option (:) available at top-right-corner of the image.
- Select the ASSIGN SCRIPT option
- Add the created function name onClickImage (not the script name test.gs)
- Now whenever you click the image, the respective assigned app script function will be triggered accordingly.