• 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
Re: get numbers from excel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get numbers from excel


  • Subject: Re: get numbers from excel
  • From: Paul Berkowitz <email@hidden>
  • Date: Sun, 11 Jan 2004 18:34:00 -0800

On 1/11/04 5:48 PM, "Gerd" <email@hidden> wrote:

> i am importing numbers from excel into AS-variables. In excel the
> number for example is 1 . In as it changed to 1.0 . Why?
> When i want to set it into a variable as number i get the error message:
>
> can't make "class pval" of 1.0 into a number .
>
> Does anybody know what is wrong? (OS X 10.2)

Excel's AppleScript uses reals for all numerical values, even where they
appear to be integers. (That probably because Excel returns a rather clunky
value of 0 for empty cells: 0.0 is necessary to indicate the number zero.
And maybe because the value really is a real!)

But the error you quote seems to indicate that your script is badly written
- the real mistake is in the script. You haven't quoted the line that
errored, but I suspect it must be something like:

tell app "Microsoft Excel"
set theContent to Value of theCell
set theContent to Value of theContent as number
end tell

i.e. you're trying to get the Value of the Value (you got it once already,
and it's 1.0)

What you want is

tell app "Microsoft Excel"
set theContent to Value of theCell
try
set theContent to theContent as number
set theContent to theContent as integer
end try
end tell


That will convert string numbers to numbers, and will also convert Excel's
standard reals to integers if possible. In the case you quoted the result
will be 1.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >get numbers from excel (From: email@hidden (Gerd))

  • Prev by Date: get numbers from excel
  • Next by Date: re: Hiding Application Processes
  • Previous by thread: get numbers from excel
  • Next by thread: re: Hiding Application Processes
  • Index(es):
    • Date
    • Thread