• 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: Retrieving cell data from Microsoft Excel 98
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Retrieving cell data from Microsoft Excel 98


  • Subject: Re: Retrieving cell data from Microsoft Excel 98
  • From: Shane Stanley <email@hidden>
  • Date: Wed, 21 Nov 2001 09:15:20 +1100

On 21/11/01 3:17 AM +1000, Robert Castles,
email@hidden, wrote:

> I'm trying to script some code to retrieve sets of data from an Excel
> Spreadsheet. Unfortunately I can't use the "R1C1" since I'm using a repeat
> function to access variable row numbers.

That doesn't matter.

> The word "Value" is highlighted in the code when this error comes up (in
> bold below)
>
> The first column of the reference file is filled with text cells and here's
> a piece of the code:
>
> to CountSwatches(dataFile)
> local cellValue, excelValue
> set cellValue to "start" as text
> set rowCount to 1
> repeat until cellValue = "end"
> tell application "Microsoft Excel"
> set cellValue to Value of Cell 1 of Row rowCount of document
> dataFile
> set rowCount to rowCount + 1
> end tell
> end repeat
> end CountSwatches
>
> I'd appreciate it if anyone has any ideas as to a fix to this error or even
> somewhere to refer to on the web.

First, you're better off referring to ranges rather than cells, and
worksheets rather than documents. So your code becomes:

set cellValue to "start"
set rowCount to 1
repeat until cellValue = "end"
tell application "Microsoft Excel"
set cellValue to Range ("R" & rowCount & "C1") of Worksheet dataFile
set rowCount to rowCount + 1
end tell
end repeat

But depending on the data, you might be able to get away with the simpler:

tell application "Microsoft Excel"
set rowCount to Row of last Row of UsedRange of Worksheet 1
end tell

--
Shane Stanley, email@hidden


  • Prev by Date: Re: ANNOUNCE: XML Tools 2.3.2
  • Next by Date: Re: Strange freeze while scripting FMP and XPRESS
  • Previous by thread: Retrieving cell data from Microsoft Excel 98
  • Next by thread: URL Access Scripting and OS X
  • Index(es):
    • Date
    • Thread