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 67
set input title to ""
set error title to "Invalid Entry!"
set input message to "Enter an integer > 0"
set error message to "The entry MUST be a positive integer."
set show input to true
set show error to true
end tell
end tell
Formatting cells via code can be done via code in a very straightforward way.
John McGimpsey tells us:
"The NumberFormat property sets the cell‘s number format similarly to the GUI by assigning a string with a valid format. (Check About custom number formats in the Excel Help.) Number formats have four parts, separated by semicolons. By default, the first is applied to positive numbers, the second to negative numbers, the third to zero, and the fourth to text. To assign a text format use the string "@":
ActiveSheet.Range("A1").NumberFormat = "+0;-0;0;@"
becomes in AppleScript:
set number format of range "A1" of active sheet to "+0;-0;0;@"
"You can also modify the application of the sections, and assign one of the eight custom font colors. For instance, this format sets numbers less than negative 100 to red within parentheses, values between -100 and +100 (inclusive) to green, and values greater than 100 to red. The non-parenthesis formats have a space the width of a parenthesis added to the right side to make sure the numbers align: "
ActiveSheet.Range("A1:A100").NumberFormat = _
"[Red][<-100](0);[Green][<=100]0_);[Red]0_);@_)"
becomes in AppleScript:
set number format of range "A1:A100" of active sheet to ¬
"[Red][<-100](0);[Green][<=100]0_);[Red]0_);@_)"
Alignment (namely left, center, right for horizontal alignment) is set using the horizontal alignment and vertical alignment properties in AppleScript. Whether to wrap text is set using the wrap text property. So:
With ActiveSheet.Range("A1:J10")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
End with
becomes in AppleScript:
tell application "Microsoft Excel"
tell range "A1:J10" of active sheet
set horizontal alignment to horizontal align center
set vertical alignment to vertical alignment center
set wrap text to true
end tell
end tell
Note that the enumeration for the horizontal and vertical alignment parameters differ, for no good reason: horizontal align center and vertical alignment center.
< Previous Page Next Page>
- SPREAD THE WORD:
- Slashdot
- Digg
- Del.icio.us
- Newsvine