I want to be able to have some macros, while writing in a Google Document.

The idea is to replace the Quick Parts in Word - so I can have the same functionality in a Google Document.

Any ideas?


2 Answers 2



Google lately added the Google Apps Script functionality in Google Documents and presented some basics on the Google Developers site.

One key feature is the sidebar. This is where the "Quick Parts" could reside. It needs however a bit of coding to do that. See the following example, made by Martin Hawksey: Sidebar

Update 27/07/2013, here's an example I wrote myself:


// global
var app = DocumentApp.getUi();

function onOpen() {
  app.createMenu('Quick Parts')
    .addItem('Document Property', 'docProperty').addToUi();

function docProperty() {
  // set variables
  var doc = DocumentApp.getActiveDocument(); 
  var fileName = doc.getName(), Id = doc.getId();
  var file = DocsList.getFileById(Id), lastUpdated = file.getLastUpdated();
  var fileOwner = file.getOwner().getEmail();

  // arrays with label and result names
  var aNames = ['File name', 'File Id', 'File Owner', 'Last updated by'];
  var aResults = [fileName, Id, fileOwner, lastUpdated];

  // create Ui  
  var Ui = UiApp.createApplication().setTitle('Quick Parts').setWidth(450);
  var vPanel = Ui.createVerticalPanel().setId('vPanel').setSize(450, 100);  
  var fTable = Ui.createFlexTable()

  // create labels
  for(var i=0, iLen=aNames.length; i<iLen; i++) {
    fTable.setWidget(i, 0, Ui.createLabel(aNames[i]));
    fTable.setWidget(i, 1, Ui.createLabel(aResults[i]));

  // add to Ui
  vPanel.add(Ui.createLabel().setText("Document Property")


enter image description here


I'm unfamiliar with Quick Parts specifically, but as to whether or not you can use macros in Google docs, they call them scripts, and you can access the script manager to make/edit scripts from Tools->Script Manager from inside a Google spreadsheet.

  • Is it available not in the spreadsheet? I need it in the docs.
    – Saariko
    Jun 26, 2013 at 19:52
  • Ah, gotcha. Jacob's answer is going to be your better bet then for sure.
    – panhandel
    Jun 27, 2013 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.