回答

0

這應該解決它,但附加菜單不能正常工作。工作過一次,然後再也不會。

function onOpen(e) { 
    var menu; 
    if(SpreadsheetApp.getActiveSpreadsheet() != null) 
    menu = SpreadsheetApp.getUi().createAddonMenu(); 
    else if(DocumentApp.getActiveDocument() != null) 
    menu = DocumentApp.getUi().createAddonMenu(); 
    else if(FormApp.getActiveForm() != null) 
    menu = FormApp.getUi().createAddonMenu(); 
    if(menu) 
    menu 
    .addItem('Text', 'func1') 
    .addToUi(); 
}