Re: AS and Excel
Re: AS and Excel
- Subject: Re: AS and Excel
- From: Thomas Fischer <email@hidden>
- Date: Wed, 21 Aug 2013 11:24:34 +0200
Hello,
Am 21.08.2013 um 03:50 schrieb 2551: set theValues to value of every cell of column 1 whose value is not 0.0
That appears to run endlessly on my machine, and even if given a range, still returns an error.
As far as I see this kills Excel, I had to shut it down by force to get it up again. I believe you need to get the end of the range. See p360 of the Excel2004AppleScriptRef.pdf:
set theEnd to get end range "A1" direction toward the bottom
That'll return a reference like this
range "[maybe.xlsx]Sheet1!$A$7" of application "Microsoft Excel"
I tested
set theEnd to (get end range ("A:A") direction toward the bottom)
which is useless as it seems to give me the number of the cell before the first empty cell, not the number of the last non-empty cell. Yvan asked (understandably) What's the need for set theSheet to sheet 1
This is a stupid left-over from another program, there should be
to control which sheet you're working on.
I didn't find anything, but killed Excel a couple of times while searching.We may drop the loop cleaning the list because the code using the returned list is :
if aValue is in theResult then # do your duty end if
If you just want to know if there is anything at all and are willing to restrict yourself to the first 100 (or 1000 or 10000) you can check
set theResult to the value of every cell in range ("A1:A1000") as string
This will give you an empty string if all cells are empty. If you need the values you can extract them from the list after you checked that there is anything at all. Thus for now I would suggest something like
tell application "Microsoft Excel" set testFile to choose file "Please select the Excel Workbook!" set fileName to testFile as string set newWorkbook to open workbook workbook file name fileName activate object sheet 1 set theValues to the value of every cell in range ("A1:A100") end tell
set theResult to {} if (theValues as string) â "" then repeat with theItem in theValues if theItem as string â "" then copy theItem as string to the end of theResult end repeat end if theResult
Best Thomas |
_______________________________________________
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