Category Archives: Forms

Relating to Forms creation and use

Themes for Google Forms

In previous posts I’ve talked about using forms to collect user data into a spreadsheet. Google has recently announced a change that now lets you customise your forms using themes.

Adding themes to your forms is a neat way to personalize and tailor them. This can include adding images to headers or form backgrounds, setting fonts (typeface, size, and colour) and aligning paragraphs. There’s also now a gallery of modern themes to choose from.

...read more

Basics: Keyboard Shortcuts in Google Drive

There are so many keyboard shortcuts in Google Drive that most people haven’t a hope of memorizing them all. That’s usually OK – you probably only ever use a few of those available, and can remember what they are – but occasionally it’s nice to have a quick reference to the others.

...read more

Custom Dialogs in Google Apps Script

In previous posts I’ve shown how to open dialogs such as alert() and prompt() to help you communicate messages to users and/or have them enter information. In addition to these pre-written dialogs, Apps Script lets you build custom modal dialogs to your own design.

A custom dialog can display a UI Service user interface inside a Google Docs document, a Sheets spreadsheet, or a Forms editor. Unlike alert() and prompt(), these custom dialogs do not pause the server-side script while the dialog is open; it carries on running.

Docs, Forms, and (the new version of) Sheets all use the following method to open the dialog:

Ui.showModalDialog()

First, we need to create the dialog in HTML. The following code goes into a new HTML file opened via the Script Editor:

<style>
   h2 { color:red; font: 20px bold verdana, helvetica, sans-serif; }
   p { font: 14px normal verdana, helvetica, sans-serif; }
   #btn { float:right; border-radius: 15px; }
</style>

<div>
<h2>Warning</h2>
<p>The action you are performing may be way too cool for some users.</p>
<p>Try to dial back the awesomeness a little now and then.</p>
<input id="btn" type="button" value="X" onclick="google.script.host.close()" />
</div>

...read more

Add a Document Sidebar with Google Apps Script

In this older post I showed you how to use the onOpen() trigger to add a menu item in the old Google Sheets. The interface is a little different in Forms, Docs and the new Google Sheets, so here we’ll look at the new syntax. We’ll then extend this functionality a little by creating a sidebar for a document.

This was how things worked in the old Sheets:

function onOpen() { 
 var sheet = SpreadsheetApp.getActiveSpreadsheet(); 
 var items = [{name:'Show dialog', functionName:'showDialog'}]; 
 sheet.addMenu('Custom Menu', items);
}

In Forms, Docs and the new version of Sheets we instead use the getUi() method of the SpreadsheetApp object (or DocumentApp, FormApp as required) to create and later display the new menu.

Here’s example code for a Document:

function onOpen() {
 DocumentApp.getUi()
     .createMenu('Sidebar').addItem('Open', 'openSidebar').addToUi();
}

...read more