Var selection = DocumentApp.getActiveDocument().getSelection()
Copy the following code into the editor:.Create a new script ( Tools > Script Editor).This is a cleaned-up solution offered by using Google App Scripts to add a custom menu action:
A lot of the solutions don't work inline.