Can Excel "Undefine" a Variable?
Can Excel "Undefine" a Variable?
- Subject: Can Excel "Undefine" a Variable?
- From: Gil Dawson via AppleScript-Users <email@hidden>
- Date: Sun, 15 Dec 2024 14:56:31 -0800
Hi-
Working on an AppleScript/Excel/... project, I have come across a second Excel oddity. Having enjoyed great success with a previous problem (Thanks, J.S.), I now present this second one:
Using Script Debugger V8.0.8 and Excel 16.90 running under Sequoia 15.2 3 in my MacBook Air M1, 2020...
The following code works jes' fine:
tell application "Microsoft Excel" set SubscriberAddress to (the value of cell "A2") log "the length of SubscriberAddress=" & the length of SubscriberAddress --(58) set SubscriberAddress to (text 15 through -1 of SubscriberAddress) -- Odd, that the following line makes "SubscriberAddress" undefined: --set SubscriberAddress to (text 15 through -1 of (the value of cell "A2")) end tell
log "SubscriberAddress=" & SubscriberAddress <-- 1735... (and so on for 58 characters. Looks OK.)
However, if I uncomment that last "set", while using the same spreadsheet, the resulting code gets an error:
tell application "Microsoft Excel" set SubscriberAddress to (the value of cell "A2") log "the length of SubscriberAddress=" & the length of SubscriberAddress --(58) set SubscriberAddress to (text 15 through -1 of SubscriberAddress) -- Odd, that the following line makes "SubscriberAddress" undefined: set SubscriberAddress to (text 15 through -1 of (the value of cell "A2")) end tell
log "SubscriberAddress=" & SubscriberAddress --(Does not execute)
The purpose of the third "set" (the commented/uncommented "set") was to consolidate the other two.
Instead, it appears that it makes the target variable become "undefined".
The workaround is simple enough, but I'm curious:
Might you have an explanation for what is happening here?
--Gil |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden