

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 70
There's definitely something missing in the AppleScript syntax that doesn't know how to fit built-in read-only elements into its model. Excel, along with Word, has its fair share of these objects. These are dealt with quite handily in VBA as Collection Objects, but become, quite literally orphans, with no parent aside from a remote progenitor base object, in AppleScript.
If you read the Word chapter, you will recall the same issue with headers and footers there. We have to do the same thing here with borders – only there are more than 6 borders. There are 12. We have to use the command get border and specify which border, 12 times over, to retrieve each of the 12 borders separately. (Word has borders too, with the same issue.)
Here is how you have to do it, if you want to set the line style and color index of all borders of a cell or range, as in the VBA snippet above:
tell application "Microsoft Excel"
tell range "D10" of active sheet
set allBorders to {} -- initialize a list
set end of allBorders to get border which border border bottom
set end of allBorders to get border which border border left
set end of allBorders to get border which border border right
set end of allBorders to get border which border border top
set end of allBorders to get border which border diagonal down
set end of allBorders to get border which border diagonal up
set end of allBorders to get border which border edge bottom
set end of allBorders to get border which border edge left
set end of allBorders to get border which border edge right
set end of allBorders to get border which border edge top
set end of allBorders to get border which border inside horizontal
set end of allBorders to get border which border inside vertical
end tell
repeat with thisBorder in allBorders
< Previous Page Next Page>

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