• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Can Excel "Undefine" a Variable?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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)


PastedGraphic-1.png


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

  • Follow-Ups:
    • Re: Can Excel "Undefine" a Variable?
      • From: Deivy Petrescu via AppleScript-Users <email@hidden>
  • Prev by Date: Re: What is "zero" in Excel?
  • Next by Date: Re: Can Excel "Undefine" a Variable?
  • Previous by thread: Re: What is "zero" in Excel?
  • Next by thread: Re: Can Excel "Undefine" a Variable?
  • Index(es):
    • Date
    • Thread