mingsai

Numbers Make and Save New Document

Feb 22nd, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Create a new document and save it into the Documents folder
  2.  
  3. -- generate the default file name
  4. set todaysDate to (current date)
  5. set the nameToUse to ¬
  6.     ("Monthly Report - " & (month of todaysDate) as string) & ¬
  7.     space & (year of todaysDate) as string
  8. --> "Monthly Report - December 2013"
  9.  
  10. -- make sure the file name is not in use
  11. set the destinationFolderHFSPath to ¬
  12.     (path to the documents folder) as string
  13. repeat with i from 0 to 100
  14.     if i is 0 then
  15.         set incrementText to ""
  16.     else
  17.         set incrementText to "-" & (i as string)
  18.     end if
  19.     set thisFileName to nameToUse & incrementText & ".numbers"
  20.     set thisFilePath to destinationFolderHFSPath & thisFileName
  21.     tell application "Finder"
  22.         if not (exists document file thisFilePath) then exit repeat
  23.     end tell
  24. end repeat
  25.  
  26. tell application "Numbers"
  27.     activate
  28.     -- create a new document and store its reference in a variable
  29.     set thisDocument to make new document
  30.     -- address the document reference
  31.     tell thisDocument
  32.         -- remove any default tables
  33.         delete every table of every sheet
  34.     end tell
  35.     -- save the document
  36.     save thisDocument in file thisFilePath
  37. end tell
Advertisement
Add Comment
Please, Sign In to add comment