Google Docs – Using Placeholders with Google Apps Script

google docsgoogle-apps-script

The document is commercial contract for my clients. Every time I fill the document I need to write the name, the address, id, etc. of my client several times in different places of the document. Since the document has 13 pages it is time wasting. Using placeholder would allow me to fill the data just one time

Is there any way to use Placeholders in Google Docs?

My {NAME} ipsum dolor sit amet, consectetuer adipiscing elit.
Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Donec {ID} quam felis, ultricies nec, pellentesque eu, pretium
quis, sem. Nulla consequat massa quis enim. Donec pede justo,
fringilla vel, aliquet nec, vulputate eget, arcu. In {ADDRESS} enim
justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum
felis eu pede mollis pretium. Integer tincidunt.

Best Answer

You could think of it as a mail-merge field: put merge fields in, and then each time you use the document to generate a contract, just have one row (the current client's details) in the data file. That said Google Documents don't directly support mail merge (yet -but I expect they will sooner or later). However there do appear to be some options - see this help forum article: http://productforums.google.com/forum/#!topic/docs/c6NBVY9xDDE

Another option is just to use a (or several) phrases that you are 100% sure won't appear anywhere else in the document (eg [CUST-NAME] ), and then use Edit > Find and replace > Replace all when you are ready to generate a document for a specific client. This is a little more work each time you set up the document, but easier to set up.