Re: Microsoft Excel
Re: Microsoft Excel
- Subject: Re: Microsoft Excel
- From: Doug McNutt <email@hidden>
- Date: Sat, 19 Feb 2005 09:06:25 -0700
At 12:11 +0000 2/19/05, Gonçalo Miguel wrote:
>Hello i'm a beginner in script. Does some one know how to script inside excel. Like create new lines whitout replacing the one before?
First, you hardly need a script for that. I use Excel 2001 on an 8500 running OS 9 but it hasn't changed that much in OS X. The Insert menu has an item "Rows". If you select an entire row and exercise that menu item Excel will insert a new row above the row you selected. (It will also modify formulas that might, but won't, apply to the new row.)
"Inside Excel" you can script that operation by selecting the Tools->Macros->Record new macro item. Select that and then execute that "Insert Rows" item. You will see a little palette window with a button in it that will allow you to stop recording. After that use Tools->Marcos->Visual Basic editor and poke around a while to find the macro you recorded. It will look like this:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/19/2005 by Douglas McNutt
Selection.Insert Shift:=xlDown
Application.CommandBars("Stop Recording").Visible = False
With ActiveWindow
.Top = 95
.Left = -717
End With
End Sub
The only thing you care about is the item:
Selection.Insert Shift:=xlDown
which is the "script inside Excel" that I think you are looking for. The language is different from AppleScript in that classes and methods have different syntax with that dot indicating that you are using method "Insert" with a property "Shift" set to a constant "xlDown" on an object "Selection".
Excel also has a well regarded AppleScript interface that allows the same kind of things to be accomplished in the "English - like" syntax of AppleScript but you will still have to get accustomed to the class, method, object, property, container culture of modern programming. Have a look at the Excel dictionary using Apple's Script Editor.
If you prepare an Excel macro in VBA - Visual Basic for Applications - you can execute that macro using AppleScript. It's easier to tell, in VBA, which words represent classes and and which are objects and methods. The English of AppleScript seems to obfuscate that a bit.
--
Applescript syntax is like English spelling:
Roughly, but not thoroughly, thought through.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >(no subject) (From: Gonçalo Miguel <email@hidden>) |