Last active
August 29, 2015 14:26
-
-
Save Slowhand0309/d50423bf92f69d80e298 to your computer and use it in GitHub Desktop.
Google Apps Script Form SetDestination
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 bindForm() { | |
// フォーム取得 | |
var formUrl = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; | |
var form = FormApp.openByUrl(formUrl); | |
// スプレットシート取得 | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId()); | |
var date = new Date(); | |
var sheetName = date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate(); | |
// シート名を変更 | |
var sheets = ss.getSheets(); | |
for (var i = 0; i < sheets.length; i++) { | |
// シート名に「フォームの回答」が含まれている場合 | |
var name = sheets[i].getName(); | |
if (name.indexOf('フォームの回答') != -1 | |
&& name.indexOf(sheetName) == -1) { | |
sheets[i].setName(sheetName); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment