Re: SCRIPTING EXCEL
Re: SCRIPTING EXCEL
- Subject: Re: SCRIPTING EXCEL
- From: David Wignall <email@hidden>
- Date: Thu, 02 May 2002 20:55:04 +1200
on 2/5/02 10:29 am, AHMD at email@hidden wrote:
>
can someone give me some basic sample in selecting text fields in Excel .
>
or tell me a link or address of scripting Excel guide
>
what I want is : to copy some text in same place of every page.
You refer to cells as range objects, using "R1C1" to identify the cell. This
is the row number and column number of the cell, rather than "A1" as it is
in the interface. You refer to sheets either by name, "Sheet1" or by index
number, Sheet 1. You do not have to select these things to work with them.
The following snippet will copy the contents of cell A1 on Sheet 1 and paste
into cell B2 on Sheet 2
CopyObject Range "R1C1" of Sheet 1
Paste Destination Range "R2C2" of Sheet 2
Another approach is to set a variable to the contents of one range and then
set the contents of another range to the variable. For example
set TheString to text of Range "R1C1" of Sheet 1
set FormulaR1C1 of Range "R2C2" of Sheet 2 to TheString
It's reasonably straight forward to use a repeat loop and variables to work
through an entire workbook. The text of a range returns the contents of the
cell, as formatted on the sheet, as a string. You can get the value of a
range, which returns the unformatted value, calculated or constant, as the
data type that it is. You can get the FormulaR1C1 of a range, which returns,
generally, what has been typed into the cell as a string. This gets
interesting with dates, but then so does Excel. If you do any of the above
with a range of cells eg text of Range ("R1C1:R10C10") then AppleScript will
return a list of items.
Finally I'll point out that Excel is recordable. In other words you can
start recording in Script Editor, switch to Excel and perform the actions
you wish. This can be very useful indeed although that does lead to a lot of
selecting that may not be necessary in code.
--
hth
Dave
_______________________________________________
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.