https://googleappsscriptrc.blogspot.com/2018/07/custom-menus.html
Last active
December 4, 2018 04:49
-
-
Save oshliaer/9422ade231c007c7a9149fed3fa13419 to your computer and use it in GitHub Desktop.
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 onOpen(){ | |
FormApp.getUi().createMenu("Моё меню") | |
.addItem("Добавить текстовое поле", "addTextField") | |
.addItem("Об этой Форме", "aboutForm") | |
.addToUi(); | |
} | |
function addTextField(){ | |
var textField = FormApp.getActiveForm().addTextItem(); | |
textField.setTitle("Новое текстовое поле"); | |
textField.setHelpText("Дополнительный текст"); | |
} | |
function aboutForm(){ | |
var dic = [ | |
{ | |
"title": "Это тест", | |
"cmd": "isQuiz", | |
"val": undefined | |
}, | |
{ | |
"title": "Принимает ответы", | |
"cmd": "isAcceptingResponses", | |
"val": undefined | |
}, | |
{ | |
"title": "Сводка ответов опубликована", | |
"cmd": "isPublishingSummary", | |
"val": undefined | |
} | |
]; | |
var message = ""; | |
var form = FormApp.getActiveForm(); | |
for(var i = 0; i < dic.length; i++){ | |
message += dic[i].title + ": " + form[dic[i].cmd]() + "\n"; | |
} | |
FormApp.getUi().alert(message); | |
} |
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 onOpen(){ | |
SpreadsheetApp.getUi().createMenu("Моё меню") | |
.addItem("Добавить новый лист", "addNewSheet") | |
.addToUi(); | |
} | |
function addNewSheet(){ | |
SpreadsheetApp.getActive().insertSheet(); | |
} |
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 onOpen(){ | |
DocumentApp.getUi().createMenu("Моё меню") | |
.addItem("Добавить новый абзац", "addNewParagraph") | |
.addToUi(); | |
} | |
function addNewParagraph(){ | |
DocumentApp.getActiveDocument().getBody().appendParagraph("Новый абзац"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment