Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

Create Keynote '09 slide from Numbers '09 selection Apps
One of the new things in Numbers '09 is AppleScript support. As an example of what's possible -- and the kind of code you'll need to use to get the current sheet and selected cells -- AppleScript guru Sal Soghoian sent in the following example. This code takes the selected cells in a Numbers table and converts them into a bulleted slide in Keynote with the selected values.
try
  tell application "Numbers"
    tell document 1
      -- DETERMINE THE CURRENT SHEET
      set current_sheet_index to 0
      repeat with i from 1 to the count of sheets
        tell sheet i
          set x to the count of (tables whose selection range is not missing value)
        end tell
        if x is not 0 then
          set the current_sheet_index to i
          exit repeat
        end if
      end repeat
      if the current_sheet_index is 0 then error "No sheet has a selected table."
      -- GET THE VALUES OF THE SELECTED CELLS
      tell sheet current_sheet_index
        set the current_table to the first table whose selection range is not missing value
        tell the current_table
          set the range_values to the value of every cell of the selection range
        end tell
      end tell
    end tell
  end tell
  -- CONVERT THE VALUES LIST TO PARAGRAPHS
  set AppleScript's text item delimiters to return
  set the bullet_points to the range_values as string
  set AppleScript's text item delimiters to ""
  -- CREATE A NEW SLIDE AND USE THE VALUES LIST AS BULLETS
  tell application "Keynote"
    activate
    tell slideshow 1
      set this_slide to make new slide at the beginning of slides
      tell slide 1
        set body to the bullet_points
      end tell
    end tell
  end tell
on error error_message
  display dialog error_message
end try
To use this, save it out of Script Editor as a script to your user's Library » Scripts » Applications » Numbers folder -- you may have to create some of the folders at/below the Scripts folder. Then within Numbers, select the range you wish to move to Keynote, and then use the Scripts menu to select and run your new script.

While this worked, it dumped the body into the subtitle section of the default new slide in Keynote. Looking at the AppleScript dictionary for Keynote '09, it appears it should be possible to create a new slide with a given master, so that the pasted data would wind up in an actual bullet body section -- but I'll leave that as an exercise for the experts!
    •    
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[8,725 views]  

Create Keynote '09 slide from Numbers '09 selection | 4 comments | Create New Account
Click here to return to the 'Create Keynote '09 slide from Numbers '09 selection' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Create Keynote '09 slide from Numbers '09 selection
Authored by: jaxjason on Fri, Jan 9 2009 at 10:38AM PST
This is great. I just firgured out the most basic applescript for numbers yesterday. I write VB and VBA all day every day for my real job and was very excited that I might be able to start doing the same thing for numbers. (automating repetitive manual Processes down to minutes from hours or days).

This is going to help me get going even faster now.
Thanks alot to the OP'er,
Jason




[ Reply to This | # ]
Create Keynote '09 slide from Numbers '09 selection
Authored by: splash6 on Sun, Jan 18 2009 at 1:27AM PST
I don't seem to be able to get this script to work with multiple sheets in a document when the bullet points are not on sheet 1. Anybody had an success with this?

[ Reply to This | # ]
Create Keynote '09 slide from Numbers '09 selection
Authored by: mr. applescript on Sat, Jan 10 2009 at 11:33AM PST
Here's the variation that assigns a master slide:
tell application "Keynote"
	activate
	tell slideshow 1
		set this_slide to make new slide at the beginning of slides
		set the master_name to "Bullets" -- or "Title & Bullets"
		if exists master slide master_name then set master of slide 1 to master slide master_name
		tell slide 1
			set body to the bullet_points
		end tell
	end tell
end tell


[ Reply to This | # ]
Create Keynote '09 slide from Numbers '09 selection
Authored by: deef on Mon, Jan 12 2009 at 8:57AM PST
Just poked around in the Applescript dictionary for Numbers '09 and I'm pretty sure it's going to get me to upgrade (sigh) from iWork '08. Looks like a huge step forward.

[ Reply to This | # ]