1

I have one Google Document with 20 pages.

I would like to insert some words with special reference as !#company_name#! into Google document with few different pages.

Use Below code:

var cursor = DocumentApp.getActiveDocument().getCursor();
var element = cursor.insertText('!#company_name#!');

We need one Toggle button through which I can replace with it's proper value as "Motorola Company LLC". That I achieved via below code:

Use Below code:

var sampleDoc = DocumentApp.openById(docId),
var docBody = sampleDoc.getBody();  
docBody.replaceText('!#company_name#!','Motorola Company LLC');

Now, I have replaced the text from '!#company_name#!' To 'Motorola Company LLC'.

Now Question: Is there any functions available in Google App script to toggle between these 2 items? So I can easily check the key and toggle it to value and toggle it to key again and so on...

Examples other key pairs:

  1. !#company_name#! :: Motorola Company LLC
  2. !#company_data#! :: 12 December 2015
  3. !#company_employee#! :: 50+

P.S: The toggle button will switch between above key & pair only.

  • Not sure if I understood correctly but, in your doc you will have !#company_name#! then you want the button that will change this value to Motorola Company LLC and then clicking on the same button it will change again to !#company_name#! ... is this correct? in your question, what do you mean with "these 2 items"? – Gerardo Dec 18 '15 at 00:16
  • @Gerardo Yes, you are right. This is what I want to achieve. – Lanover Solutions Dec 18 '15 at 04:49

0 Answers0