Subject: Re: Scope riddle I can't seem to solve. (Probably very easy to solve for an experienced coder)
Date: March 21, 2014 at 12:04:46 AM PDT
global WB, WS1
to test_scope(sheetReference)
tell application "Microsoft Excel"
activate
tell sheet sheetReference
activate
get address of active cell
end tell
end tell
end test_scope
on DD(msg)
display dialog msg buttons {"OK"} default button 1
end DD
tell application "Microsoft Excel"
set WB to workbook "TestBook"
set WS1 to sheet "one"
set WS2 to sheet "two"
set WS3 to sheet "three"
get address of active cell
end tell
my test_scope(WS1)
tell WB
activate WS1
end tell
This script is generating an error on the highlighted line (in red):
Microsoft Excel got an error: The object you are trying to access does not exist
This is the offending object:
active cell of sheet («class asDB» id (application "Microsoft Excel") of worksheet 1) of application "Microsoft Excel"
I notice there a two references to Microsoft Excel in the object evaluation, is this a syntactical issue that I can clean up because I'm referencing to Excel in the tell statement and in the variable?
Or is it still a scope issue?