S'il n'est pas trop tard pour toi ... quoique il doit être 20:16
prend une copie de :
https://docs.google.com/spreadsheets/d/18pA0Ri05e7f3MOmP1BGr9d3w_T2ao9HylXZKVDaIFqA/edit?usp=sharing
Pour le fonctionnement, plutôt que 21 boutons, tu cliques dans le menu sur Texto > Ouvrir interface
Il faudra demander les autorisations ... pour cela, dans Outils > Editeur de script
, fais exécuter une première fois.
function onOpen(e) {
SpreadsheetApp.getUi()
.createMenu('🎭Texto🎭')
.addItem('Ouvrir interface', 'showSidebar')
.addToUi();
}
function showSidebar(){
var ui = SpreadsheetApp.getUi();
var html = HtmlService
.createTemplateFromFile("index")
.evaluate();
html.setTitle("Choix du cas à envoyer :");
ui.showSidebar(html);
}
function monresult(n){
try {
var doc = SpreadsheetApp.getActiveSpreadsheet();
var feuille = doc.getSheetByName('Feuille 2');
if (n<=7){
var r=feuille.getRange(1,2*n-1);
feuille.setActiveSelection(r.getA1Notation());
}else if(n<=14){
var r=feuille.getRange(15,2*(n-7)-1);
feuille.setActiveSelection(r.getA1Notation());
}else{
var r=feuille.getRange(30,2*(n-14)-1);
feuille.setActiveSelection(r.getA1Notation());
}
var destinataire = r.offset(8,0).getValue();
var titre = r.offset(3,0).getValue();
var texte = '';
for (var ligne=1;ligne<=12;ligne++){
texte = texte + r.offset(ligne,0).getValue() + '\n';
}
if (destinataire != ''){
GmailApp.sendEmail(destinataire.replace(/[-]/g, "") + '@txt.bell.ca', titre, texte) ;
Browser.msgBox('#' + n + ' envoyé à ' + destinataire + ' !');
}else{
Browser.msgBox('Absence de destinataire !');
}
}
catch(err) {
var valide = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
Browser.msgBox('Erreur ' + err + ' !');
}
};
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<style>
body{margin:12px;}
td{width:48px;}
</style>
</head>
<body>
<form>
<table><tr>
<td><input type="radio" name="cas" value="1">1</td>
<td><input type="radio" name="cas" value="2">2</td>
<td><input type="radio" name="cas" value="3">3</td>
</tr><tr>
<td><input type="radio" name="cas" value="4">4</td>
<td><input type="radio" name="cas" value="5">5</td>
<td><input type="radio" name="cas" value="6">6</td>
</tr><tr>
<td><input type="radio" name="cas" value="7">7</td>
<td><input type="radio" name="cas" value="8">8</td>
<td><input type="radio" name="cas" value="9">9</td>
</tr><tr>
<td><input type="radio" name="cas" value="10">10</td>
<td><input type="radio" name="cas" value="11">11</td>
<td><input type="radio" name="cas" value="12">12</td>
</tr><tr>
<td><input type="radio" name="cas" value="13">13</td>
<td><input type="radio" name="cas" value="14">14</td>
<td><input type="radio" name="cas" value="15">15</td>
</tr><tr>
<td><input type="radio" name="cas" value="16">16</td>
<td><input type="radio" name="cas" value="17">17</td>
<td><input type="radio" name="cas" value="18">18</td>
</tr><tr>
<td><input type="radio" name="cas" value="19">19</td>
<td><input type="radio" name="cas" value="20">20</td>
<td><input type="radio" name="cas" value="21">21</td>
</tr>
</table>
</form>
<br>
<div id="lastButtonBlock" class="block">
<button onclick="myFunction()" class ="action button actionButton" > VALIDER </button>
</div>
<script>
function myFunction() {
var x = (document.forms.length)-1;
var cas = document.forms[x];
var n=0;
var i;
for (i = 0; i < cas.length; i++) {
if (cas[i].checked) {
n = cas[i].value ;
}
}
google.script.run.monresult(n)
for (i=0; i < cas.length; i++){
//Si balise de type radio on met checked = false
if(cas[i].type == 'radio') {
cas[i].checked = false
};
}
};
</script>
</body>
</html>
On peut faire beaucoup plus simple si tu veux, j'ai juste voulu privilégier l'interface.