

Moving from Microsoft Office VBA to AppleScript:
MacTech's Guide to Making the Transition
Introduction
|
Table of Contents
Page Prev and Page Next buttons at bottom of the page.
|
April, 2007
Page 71
try
set line style of thisBorder to double
end try
try
set color index of thisBorder to 3
end try
end repeat
end tell
In this case, we set the end of a list to each new border, which is a more efficient way of building a list than concatenating the lists as we did with the Word headers and footers. It makes no discernable difference when you've just got just one or a few items to process, but if you had to repeat this whole procedure hundreds of times over, it could make a significant difference to the speed of the script.
Unfortunately, again, we can't set the line style (nor any other property) of the whole list at once, in this case. The script errors (even if you can exclude any nonexistent borders). So we have to run a repeat loop on each member of the list, using try/end try for each border. In the case of a standard default worksheet cell, both commands error on the last two borders (inside horizontal and inside vertical) which may mean that they don't really exist, although some object is returned from the get border command each time.
Since we can't run a command (set line style, etc.) on the whole list at once, there isn't much advantage in having the list. We could instead set the line style and color index for each border as we make it, sending each border out to a handler to be processed, like this:
tell application "Microsoft Excel"
tell range "D10" of active sheet
set thisBorder to get border which border border bottom
my ModifyBorder(thisBorder)
set thisBorder to get border which border border left
my ModifyBorder(thisBorder)
set thisBorder to get border which border border right
my ModifyBorder(thisBorder)
set thisBorder to get border which border border top
my ModifyBorder(thisBorder)
set thisBorder to get border which border diagonal down
my ModifyBorder(thisBorder)
set thisBorder to get border which border diagonal up
my ModifyBorder(thisBorder)
set thisBorder to get border which border edge bottom
my ModifyBorder(thisBorder)
< Previous Page Next Page>

- SPREAD THE WORD:
- Slashdot
- Digg
- Del.icio.us
- Newsvine