我目前正在从VBA切换,并尝试在Google表格中实现不可能。
我的整个项目是制作一个脚本,该脚本在单击按钮后在边栏/弹出窗口中打开一个表单,并将插入到表单中的值保存在某些工作表中。根据我在这里学到的知识和阅读的内容,我设法使它达到以下条件:
var ss = SpreadsheetApp.getActiveSpreadsheet(),
sheet = ss.getActiveSheet(),
ui = SpreadsheetApp.getUi(),
cell = sheet.getCurrentCell(),
val = cell.getValue(),
col = cell.getColumn(),
row = cell.getRow();
if (col === 7 && row > 7 && val !== 'Description: ') {
// ui.alert('OK');
launchForm();
} else
ui.alert('Wrong row selected');
}
function launchForm() {
var formID = '1OHk3sHIoxZm0__eRHfVBsOxwPCgQARYHCnzC3O6B_3Q';
var form = FormApp.openById(formID);
var formUrl = form.getPublishedUrl();
var response = UrlFetchApp.fetch(formUrl);
var formHtml = response.getContentText();
var htmlApp = HtmlService
.createHtmlOutput(formHtml)
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setTitle('NEW RECORD')
.setWidth(500)
.setHeight(450);
SpreadsheetApp.getActiveSpreadsheet().show(htmlApp);
}
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Launch Form",
}];
sheet.addMenu("Custom Menu", entries);
};
一切正常,但是表单上的“提交”按钮根本不起作用,并且不记录输入。有人可以帮忙吗?
我相信克服这一点将帮助我完成整个项目。