user2962739
user2962739

Reputation: 11

How do i use DocumentApp.getui() on a new doc

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

Answers (1)

Mogsdad
Mogsdad

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

Related Questions