Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

copy and paste values error

Howdy folks. Need another pair of eye to help push me in the right direction. I’m trying to write an applescript that will copy the value of a formula in one worksheet and paste it into another. cell g7 contains a countif formula. i am trying to get the value of the formula from the annual xlxx and paste it to cell am3 of the payroll xlxx. When I tried to compile the script a, I got an Expected end of line, etc. but found end of script” error. Can someone please take a look at it and see what I’ve done wrong?


tell application "Finder"

activate

set annual_path to alias "Users:macbook:Desktop:DSHS Reports:DOEP Annual Report:Drug Annual Report.xlsx"

open document file annual_path


set payroll_path to alias":Users:macbook:Desktop:Instructor Payout.xlsx"

open document file payroll_path


tell application "Microsoft Excel"

set annual_book to (open workbook workbook file name (annual_path as string))

set annual_doc to worksheet 2 of annual_book

set payroll to worksheet "sheet1" of (open workbook workbook file name (payroll_path as string))



tell annual_doc

set ben to range "G7"

end tell


tell payroll

set value of cell "AM3" to ben

end tell


save annual_book

close annual_book


save active workbook in payroll_path

close active workbook

end tell

Posted on Jul 13, 2014 7:39 AM

Reply
8 replies

Jul 13, 2014 1:40 PM in response to Tony T1

grrrr... I hate when this happens... I can get it to compile if i change the script, but i get a couple of different messages.


tell payroll

set value of "AM3" to ben

end tell

returns this error:

Can’t set value of "AM3" to «class ccel» "G7" of «class XwSH» 2 of «class X141» "Drug Annual Report.xlsx" of application "Microsoft Excel".

tell payroll

set value of AM3 to ben

end tell

returns this error:

The variable AM3 is not defined.

Jul 13, 2014 2:10 PM in response to samiam2356

samiam2356 wrote:


can you post the script you are using? there's gotta be something you're doing differently than what i am doing. if they are the same don't understand ow it can work with one but not the other.


I just copied the script you posted, added the end tell, then changed the worksheets to Users:Tony:Desktop:test1.xls and Users:Tony:Desktop:test2.xls

In cel G7 I used an =sum() formula

So, the only real difference is that you're opening an .xlsx file and I tested with an .xls file

copy and paste values error

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.