Reputation: 11
So i have been trying to make a script that makes a doc and then uses Document.getUi()
var doc = DocumentApp.create('New')
var Func = DocumentApp.getUi() //Blah blah blah
but when I do this it gives me an error how can i fix this.
Upvotes: 1
Views: 2391
Reputation: 45720
The error received is:
Cannot call DocumentApp.getUi() from this context.
This is consistent with the documentation for getUi()
:
"A script can only interact with the UI for the current instance of an open document, and only if the script is bound to the document."ref
Since your script has created a new document, "doc
" it's obviously not contained in it - therefore it cannot manipulate the UI for doc
.
Upvotes: 2