Pages autosave

Discussion in 'Mac Programming' started by lynkynpark86, Nov 22, 2010.

  1. macrumors 6502

    #1
    Due do my recent loosing of 70+ pages of writing, I decided to write a script to autosave pages for me. It may look a little flawed (only saves one document at a time), but I have written this for my needs, exactly how I want it to work. Unfortunately, it gets an error every time
    Code:
    set xyz to text returned of (display dialog "Enter name of document to autosave" default answer "" buttons {"OK"} default button "OK")
    set uptime to 0
    repeat
    	delay 60
    	set uptime to uptime + 1
    	if uptime ≥ 5 then
    		tell application "Pages"
    			save document xyz
    			display alert "Autosaved"
    		end tell
    		set uptime to 0
    	end if
    end repeat
    
    it says it "cannot get document (name of document typed) of application "pages"
    please help me with this
    :apple:
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Your script worked for me (Pages '08), but why not make it auto-save everything:

    Code:
    set uptime to 0
    repeat
        delay 60
        set uptime to uptime + 1
        if uptime ≥ 5 then
            tell application "Pages"
                repeat with doc in every document
                    save doc
                    display alert "Autosaved \"" & name of doc & "\""
                end repeat
            end tell
            set uptime to 0
        end if
    end repeat
    Or just get in the habit of hitting ⌘-s frequently :)
     

Share This Page