Search code examples
google-apps-scriptgoogle-sheetsscriptinggoogle-docs

Get wordcount automatically in google sheets from google docs


I have used the code from an earlier post, see link below:

Paste Google Docs URLs into Google Sheets and automatically get title and word count

I am doing, to the best of my knowledge, the same thing as described in the post in the link above but I can't get the script to work. It still shows the same error message:

Exception: You do not have permission to call DocumentApp.openByUrl. Required permissions: https://www.googleapis.com/auth/documents (rad 82).

What am I missing? According to the previous post it should work if you use a custom menu call instead of a custom function. Thanks in advance! /K


Solution

  • You need to type the function names in UPPERCASE. Exactly like they are in the script:

    function GETDOCWORDCOUNT(url)
    
    function GETDOCTITLE(url)
    

    Here is workflow for GETDOCTITLE() enter image description here

    It will show the error again.

    Keep calm and click on Custom script > Run GETDOCTITLE

    enter image description here

    And here we go:

    enter image description here