如何从自定义菜单项打开Google表单 [英] How do you open a Google form from a Custom Menu Item
问题描述
我是Google Script的新手,我正在尝试创建一个Google表单来管理行情的创建....我创建了一个可以捕获报价细节的表单,我希望用户能够点击在工作表顶部的菜单项上点击创建新的报价单,这将打开表单。
创建时可以使用什么命令代替以下内容菜单项是这样的,将打开表单....我需要在任何地方参考表单ID? code> function onOpen(){
var ui = SpreadsheetApp.getUi();
//或DocumentApp或FormApp。
ui.createMenu('Quote Generator Menu')
.addItem('Create New Quote','menuItem1')
.addItem('Update Lists','updateLists')
.addSeparator()
.addSubMenu(ui.createMenu('Reporting')
.addItem('Dashboard','menuItem2'))
.addToUi();
}
function menuItem1(){
SpreadsheetApp.getUi()//或DocumentApp或FormApp。
.alert('您点击了创建新报价');
}
function menuItem2(){
SpreadsheetApp.getUi()//或DocumentApp或FormApp。
.alert('您点击了Dashboard');
}
点击菜单后:
- 创建一个UI应用程序。
- 创建发布表单的超链接,指示用户单击链接添加新报价。
- 添加链接到UI应用程序。
- 显示UI应用程序。
示例:
function onOpen(){
var ui = SpreadsheetApp.getUi();
ui.createMenu('报价生成器菜单')
.addItem('创建新报价','showUrl')
.addToUi();
}
// http://stackoverflow.com/questions/26815296
function showUrl(){
var FORM_URL =ENTER_FORM_URL_HERE;
var app = UiApp.createApplication()。setHeight(50).setWidth(200);
app.setTitle(提交新报价);
var link = app.createAnchor('点击这里提交新报价',FORM_URL);
app.add(link);
var doc = SpreadsheetApp.getActive();
doc.show(app);
单击菜单后弹出的UI提示屏幕截图:
I am brand new to Google Script and I am trying to create a Google Sheet to manage the creation of Quotes....I have created a form that will capture the Quote details and I want the user to be able to click on a Menu item at the top of the Sheet to "Create New Quote" which will open the Form.
What command can I use in place of the following when creating the Menu Item so that is will Open the Form....do I need to refer to the Form ID anywhere ?
function onOpen() { var ui = SpreadsheetApp.getUi(); // Or DocumentApp or FormApp. ui.createMenu('Quote Generator Menu') .addItem('Create New Quote', 'menuItem1') .addItem('Update Lists', 'updateLists') .addSeparator() .addSubMenu(ui.createMenu('Reporting') .addItem('Dashboard', 'menuItem2')) .addToUi(); } function menuItem1() { SpreadsheetApp.getUi() // Or DocumentApp or FormApp. .alert('You clicked Create New Quote'); } function menuItem2() { SpreadsheetApp.getUi() // Or DocumentApp or FormApp. .alert('You clicked Dashboard'); }
解决方案One quick and dirty way. Upon menu click:
- Create a UI app.
- Create a hyperlink to the published form, instructing user to click link to add a new quote.
- Add link to UI app.
- Display UI app.
Example:
function onOpen() { var ui = SpreadsheetApp.getUi(); ui.createMenu('Quote Generator Menu') .addItem('Create New Quote', 'showUrl') .addToUi(); } // http://stackoverflow.com/questions/26815296 function showUrl(){ var FORM_URL = "ENTER_FORM_URL_HERE"; var app = UiApp.createApplication().setHeight(50).setWidth(200); app.setTitle("Submit New Quote"); var link = app.createAnchor('Click to here to submit a new quote', FORM_URL); app.add(link); var doc = SpreadsheetApp.getActive(); doc.show(app); }
Screenshot of UI prompt that pops up after clicking the menu:
这篇关于如何从自定义菜单项打开Google表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!