问题
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.
回答1:
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
.
来源:https://stackoverflow.com/questions/19920041/how-do-i-use-documentapp-getui-on-a-new-doc