Reputation: 21
I can't run the code and I don't get what's wrong with it.
function onOpen(a) {
var ui = DocumentApp.getUi() // ..
}
Error:
Cannot call DocumentApp.getUi() from this context. (line 2, file "Code")
Upvotes: 1
Views: 2250
Reputation: 64140
This works in a Spreadsheet: function onOpen(e) { SpreadsheetApp.getUi().alert('Hello')}
This works in a Document: function onOpen(e) { DocumentApp.getUi().alert('Hello'); }
I would move the onOpen(e) function definition out of the onInstall(e) function definition.
Upvotes: 4