Embedding content from one Google Doc into another

Hey everyone,

I’m trying to figure out if there’s a way to insert the contents of one Google Doc into another. Kind of like how Microsoft Word has that IncludeText field thing.

Here’s my situation: I’ve got this custom header I want to use in all my docs. But copy-pasting it every time is a pain, especially if I need to update it later. It would be awesome if I could just put something like {{header}} at the top of each file and have it automatically pull in the content.

I tried making a Google Apps Script that copies the current doc and replaces {{header}} with text from another doc. But it only works with plain text, and I need to keep the formatting, tables, and images.

Has anyone found a good solution for this? I’m thinking maybe I need to locate all instances of the string and then go through each element of the header doc to insert it properly. But that seems like a lot of work. There’s gotta be an easier way, right?

Any ideas or suggestions would be super helpful. Thanks!

hey, i found a neat trick for this! try using the ‘Docs to Docs’ add-on. it lets u insert content from other docs and keeps formatting. just install it, pick ur source doc, and boom - it updates automatically when the original changes. saved me tons of time with headers n stuff. might be worth checking out!

I’ve actually wrestled with this exact problem before, and I can tell you from experience that it’s not as straightforward as we’d like it to be. Unfortunately, Google Docs doesn’t have a built-in feature for dynamically embedding content from one doc into another.

That said, I found a workaround that might help. I created a Google Apps Script that uses the DocumentApp class to insert content from one doc into another, preserving formatting. It’s not perfect, but it handles most formatting, tables, and even simple images.

The script basically loops through the elements of the source doc and copies them into the target doc. It’s a bit more complex than a simple text replacement, but it works well for headers and footers.

One caveat: you’ll need to run the script manually each time you want to update the embedded content. It’s not automatic like a Word field, but it’s still faster than copy-pasting and reformatting every time.

If you’re comfortable with scripting, I’d be happy to share some code snippets that might get you started. Just let me know if you want to go down that rabbit hole!

I’ve faced similar challenges with document templating in Google Docs. While there’s no native solution, I found a decent workaround using Google Slides. Here’s what I do:

  1. Create a master slide with your header content.
  2. In each document, insert a linked slide from the master.
  3. Any updates to the master slide will propagate to all linked instances.

It’s not perfect - you’ll need to adjust for different page sizes, and it doesn’t work for footers. But for headers, it’s quite effective. The linked slides maintain formatting and auto-update.

Another option is using the ‘Paste and match style’ feature for quick formatting-preserved copies. It’s manual, but faster than reformatting each time.

These methods aren’t as seamless as Word’s fields, but they’ve saved me considerable time in my workflow.