Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Right now I'm copy and pasting between Excel and specified places in a Pages document. For instance, I'll copy cell B7 and find "B7_Value" in Pages and replace it with the copied value. Here's an example of what I'm working with so far:

tell application "Microsoft Excel"
tell active workbook
    activate object worksheet "Page 1"
    set var_B7 to string value of range "B7" of active sheet        
end tell
end tell

set var_B7 to replaceText(var_visits, " ", "")

tell application "Pages"
activate
tell application "System Events"

    delay 0.5

    keystroke "f" using command down
    set the clipboard to "B7_Value"
    keystroke "v" using command down
    delay 0.2
    keystroke tab
    delay 0.2
    set the clipboard to var_B7
    keystroke "v" using command down
    delay 0.2
    keystroke tab
    delay 0.2
    keystroke space
    delay 0.2
    key code 53 -- escape
    delay 0.5

end tell
end tell

on replaceText(theString, fString, rString)
    set current_Delimiters to text item delimiters of AppleScript
    set AppleScript's text item delimiters to fString
    set sList to every text item of theString
    set AppleScript's text item delimiters to rString
    set newString to sList as string
    set AppleScript's text item delimiters to current_Delimiters
    return newString
end replaceText

Now, I need to expand this to copy a range of cells and populate chart data in Pages. Any help is very much appreciated.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.