Chris A
Chris A

Reputation: 1090

Created a script which I want to be available for all documents

I've created a fairly simple script which finds English and replaces it with Spanish words.

function translatesp() {
var body = DocumentApp.getActiveDocument()
  .getBody();

body.replaceText('Master Change Log', 'Historial de Cambios');
body.replaceText('Prepared for:', 'Preparado para:'); 
body.replaceText('Git Reference', 'Referencia Git');

}

But the function is only available on the document in which I created the code. How can I make this available in all instances of Google Docs? Sorry if this has been asked before, I did search but couldn't find anything.

Upvotes: 0

Views: 79

Answers (1)

Nico
Nico

Reputation: 316

Two ways I know of:

  1. Publish it to the Google Docs Template Gallery. If you are a G Suite user, you can limit its visibility to your domain. Otherwise, the template is available for anyone to use. Using this approach, you will have to select the template in a new doc to use the function.
  2. Publish it as a Docs Add-on. There's a bit of rigmarole required to publish, but once done, you can enable it from the Add-ons menu in any doc. Once again, if you are a G Suite user, you can limit the visibility of the Add-on to people within your organization. If you expect that you will add more custom functions in the future, this is a much more streamlined approach.

Upvotes: 1

Related Questions