如何从自定义菜单项打开Goog​​le表单 [英] How do you open a Google form from a Custom Menu Item

查看:105
本文介绍了如何从自定义菜单项打开Goog​​le表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是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');
}


解决方案

点击菜单后:


  1. 创建一个UI应用程序。

  2. 创建发布表单的超链接,指示用户单击链接添加新报价。
  3. 添加链接到UI应用程序。

  4. 显示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:

    1. Create a UI app.
    2. Create a hyperlink to the published form, instructing user to click link to add a new quote.
    3. Add link to UI app.
    4. 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:

    这篇关于如何从自定义菜单项打开Goog​​le表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆