Created
June 14, 2023 11:42
-
-
Save ochilab/1224b58b2ec96ce45e891ac5b39e8d7b to your computer and use it in GitHub Desktop.
GAS: GoogleSheet上の画像にスクリプトを動的に割り当てる(複数の画像を配置した場合)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function assignScriptsToImages() { | |
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); | |
var images =sheet.getImages(); | |
for(var i=0;i<images.length;i++){ | |
switch(images[i].getAltTextTitle()){ | |
case "risu": | |
images[i].assignScript("risuSay"); | |
break; | |
case "momo": | |
images[i].assignScript("momoSay"); | |
break; | |
} | |
} | |
} | |
function risuSay(){ | |
Browser.msgBox("りすだよ"); | |
} | |
function momoSay(){ | |
Browser.msgBox("モモだよ"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment