2017-03-05 71 views
0
function onOpen() { 
    var ui = SpreadsheetApp.getUi(); 
    // Or DocumentApp or FormApp. 
    ui.createMenu('Useful Information') 
     .addItem('How do I Book?', 'menuItem1') 
     .addSeparator() 
     .addItem('Where do I Screenshot?', 'menuItem2') 
     .addSeperator() 
     .addItem('How do I Book?', 'menuItem1') 
     .addSeparator() 
} 

function menuItem1() { 
    var app = UiApp.createApplication().setHeight('60').setWidth('150'); 
    app.setTitle("Here is a helpful link to the guide"); 
    var panel = app.createPopupPanel() 
    var link = app.createAnchor('Click here! :D','http://prntscr.com/eg5x59'); 
    panel.add(link); 
    app.add(panel); 
    var doc = SpreadsheetApp.getActive(); 
    doc.show(app); 
} 

function menuItem2() { 
    var app = UiApp.createApplication().setHeight('60').setWidth('150'); 
    app.setTitle("Here is a link to the radio"); 
    var panel = app.createPopupPanel() 
    var link = app.createAnchor('Screenshot the red box using Lightshot','http://habboun.com/radio'); 
    panel.add(link); 
    app.add(panel); 
    var doc = SpreadsheetApp.getActive(); 
    doc.show(app); 
} 

function menuItem3() { 
    var app = UiApp.createApplication().setHeight('80').setWidth('150'); 
    app.setTitle("Here is a link to the DOR page"); 
    var panel = app.createPopupPanel() 
    var link = app.createAnchor('Post your Screenshot here on the most recent Special Task. Format is dd/mm/yy - HH:MM-HH:MM', 'http://habboun.com/content/department-radio'); 
    panel.add(link); 
    app.add(panel); 
    var doc = SpreadsheetApp.getActive(); 
    doc.show(app); 
} 

內這個錯誤,所以我收到此錯誤http://prntscr.com/eg9ftl 和我不知道如何解決它。請幫幫我。我查看了不同的論壇和一切,但我找不到解決方案,因爲大多數解決方案都針對特定項目。我不知道在谷歌片的腳本編輯器

+0

另外,請注意了UiApp已被棄用,不應該使用.. https://開頭開發商。 google.com/apps-script/reference/ui/ui-app –

回答

0

告訴你的錯誤是

TypeError: Cannot find function addSeperator in object Menu. 

「addSeperator」 的拼寫錯誤。請從addSeperator更改爲addSeparator。並且「addToUi」對於您的onOpen()也是必需的。所以,你的onOpen()腳本

來源:

function onOpen() { 
    var ui = SpreadsheetApp.getUi(); 
    // Or DocumentApp or FormApp. 
    ui.createMenu('Useful Information') 
     .addItem('How do I Book?', 'menuItem1') 
     .addSeparator() 
     .addItem('Where do I Screenshot?', 'menuItem2') 
     .addSeperator() 
     .addItem('How do I Book?', 'menuItem1') 
     .addSeparator() 
} 

要:

function onOpen() { 
    var ui = SpreadsheetApp.getUi(); 
    // Or DocumentApp or FormApp. 
    ui.createMenu('Useful Information') 
     .addItem('How do I Book?', 'menuItem1') 
     .addSeparator() 
     .addItem('Where do I Screenshot?', 'menuItem2') 
     .addSeparator() 
     .addItem('How do I Book?', 'menuItem1') 
     .addSeparator() 
     .addToUi(); 
} 
相關問題