Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

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?

share|improve this question
    
I've revised my answer. –  Jacob Jan Tuinstra Jul 27 '13 at 21:13
1  
Saariko, I've given you a head start on using the site bar functionality in Google Documents. Do you expect that I (we) programme everything you ask for? –  Jacob Jan Tuinstra Aug 1 '13 at 9:09

2 Answers 2

up vote 2 down vote accepted

Introduction

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:

Code

// 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()
    .setStyleAttribute('borderCollapse','collapse');

  // 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")
    .setStyleAttribute('font-size','175%'));
  vPanel.add(fTable);
  app.showSidebar(Ui.add(vPanel));
}

Screenshot

enter image description here

share|improve this answer

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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