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?
Web Applications Stack Exchange is a question and answer site for power users of web applications. It only takes a minute to sign up.
Sign up to join this communityI 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?
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()
.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));
}
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.