Google SpreadSheet Scripts for Better Printing

Justin | GoogleDocs | Tuesday, February 14th, 2012

I’ve been using Google Docs more lately. Especially for spreadsheets. One thing that I noticed when trying to print is the effect of excess empty cells. When you choose File > Print in Google Docs, the system renders a PDF from the server and prompts you to save that PDF. If you have several empty rows and column, those will be included in your PDF. If you selected Fit to Page (the default), your text (like mine) could be tiny. I went looking for a Set Print Area option similar to the one found in MS Excel, but could not find it. So I wrote a few custom scripts to solve the issue instead.

Locating the Scripts

The 2 scripts below have been submitted to the Google Script Gallery and should be available by choosing Tools > Script gallery… then searching for the term crop. As of writing this post, the first script below is already available.

I’m including the code below in case anyone has difficulty finding them or would like to copy and modify the code for their own purposes.

Crop to Selection

Crops cells to the current selection for better printing.
function cropToSelection() {
  var sSheet = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = sSheet.getActiveSheet();
  var range = sSheet.getActiveSelection();
  var startCol = range.getLastColumn();
  var startRow = range.getLastRow();
  var endCol = sheet.getMaxColumns();
  var endRow = sheet.getMaxRows();
  try{sSheet.deleteColumns(startCol, endCol - startCol);} catch(e){};
  try{sSheet.deleteRows(startRow, endRow - startRow);} catch(e){};
}

Crop All Sheets

Crops each sheet in the worksheet to the cells that contain content.
function cropAllSheets() {
  var sSheet = SpreadsheetApp.getActiveSpreadsheet();
  var numSheets = sSheet.getNumSheets();
  var sheets = sSheet.getSheets();
  var i;
  for(i=0; i < numSheets; i++){
    var sheet = sheets[i];
    var range = sheet.getDataRange();
    sheet.setActiveSelection(range);
    var startCol = range.getLastColumn();
    var startRow = range.getLastRow();
    var endCol = sheet.getMaxColumns();
    var endRow = sheet.getMaxRows();
    if(endCol > startCol) sheet.deleteColumns(startCol, endCol - startCol);
    if(endRow > startRow) sheet.deleteRows(startRow, endRow - startRow);
  }
}

EaseCaddy Pro Released

Justin | Animate/Flash,animation,extensions | Thursday, February 9th, 2012

There is now a Pro version of our popular EaseCaddy extension (original post). The EaseCaddy panel is a Flash extension that allows you to to store, import, export, and apply custom eases.

The basic version of EaseCaddy is still totally free. By upgrading to the Pro version, you’ll be able to apply an ease to multiple tweens (motion and/or classic) simultaneously.

You can find more information about the new version of EaseCaddy on the product page.

Creating Flash Extensions – Responding to a Dialog Choice

Justin | jsfl,Tutorials | Monday, January 9th, 2012

In a previous tutorial, I showed the basics of creating dialogs. In this post, I’ll elaborate on how to respond to a dialog, specifically how to cease execution when the user has selected cancel.

Here’s the code sample that was included in the aforementioned tutorial:

if (result == null) {
//do nothing
} else {
//use the value of result to proceed with the script
}

This example reflects code for custom XMLUI panel, but this technique can also be used for alerts, prompts, and confirmations.

There are 2 easy ways to halt the script if the user has selected cancel and the result is null:

  1. Call a function only if the result is not null.
  2. If the conditional statement above occurs inside a function block, call return to exit the function.

Here’s a code sample for method 1:

var dom = fl.getDocumentDOM();
var xpanel = dom.xmlPanel(absoluteFileLocation);
if (result == null) {
//do nothing
} else {
run();
}

You’d then define a function that execute all of the requisite code:
function run(){
//all the action takes place here
}

If the result is null, the function is never triggered.

Here’s a sample for method 2:

run();
function run(){
var dom = fl.getDocumentDOM();
var xpanel = dom.xmlPanel(absoluteFileLocation);
if (result == null) return;
//continue executing otherwise
}

Essentially, the entire process is wrapped in a function, so it’s easy to jump right out when needed.

Either method will do, sometimes one method suits a particular script.

Quick Tip: Installing Adobe Extensions

Justin | extensions,tips | Wednesday, November 16th, 2011

If you have multiple versions of Adobe (or Macromedia) software installed, you probably have multiple versions of Extension Manager, the application that helps you install and manage extensions. This can lead to some confusion.

When you double-click an MXP (or ZXP) file, your operating system open your default version of Extension Manager. This may not be the version that you want, however. Suppose you have Flash Pro CS4 and Flash Pro CS5 installed. Your system will (probably) automatically launch Extension Manager CS5 when you attempt to install a new extension. This is okay if you want to install the extension in Flash CS5, but it will not be available in Flash CS4.

There are other issues that crop up when you have versions installed in multiple languages (and in some cases, if your language is not English). Luckily, there’s a simple way ensure that you’re using the correct version of Extension Manager.

  1. Launch the version of Flash Pro (or Dreamweaver, or Fireworks) in which you’d like to install the extension.
  2. Go to Help > Manage Extensions… and it will launch the matching installation of Extension Manager.

SmartMouth Version 1.1 Now Available

Justin | Animate/Flash,animation,extensions,software | Monday, November 7th, 2011

We’ve just released version 1.1 of the SmartMouth Flash extension with a couple of added features to help with the lip syncing process. This update is FREE to anyone who has already purchased licenses of SmartMouth.

Once you’ve downloaded and installed the new version, you should see a button at the bottom of the SmartMouth panel that says Advanced…

New Advanced Features

The Advanced button will bring up a window with 2 new options.

Looping

Loop settings allow you to control the loop setting applied to the outputted symbol instance(s). This can be applied if you want to animate each mouth shape, rather than use static images.

Keyframe Frequency

Keyframe Frequency allows you to control the frequency of keyframes that are automatically generated (1s – every frame, 2s – every other frame, or 3s – every third frame). You can use this setting to animate your mouth at a frame rate lower than that of the rest of your animation. For example, your animation might be set to 30 fps, but you want your mouth to animate at 15 fps, so that the mouth doesn’t look frantic. In this case, you could select 2s.

The image below demonstrates the different outputs generated by altering the Keyframe Frequency.

These new features are based on user requests. Please let us know what you think!

Page 30 of 55« First...1020...2829303132...4050...Last »