Re: Applescript Script fails with Excel 2004
Re: Applescript Script fails with Excel 2004
- Subject: Re: Applescript Script fails with Excel 2004
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 27 Nov 2005 09:17:15 -0800
- Thread-topic: Applescript Script fails with Excel 2004
On 11/27/05 6:54 AM, "Robert Poland" <email@hidden> wrote:
> Hi,
>
> I just updated to Microsoft Office 2004 from Office X.
>
> The first script I tried failed miserably.
>
> tell application "Microsoft Excel"
> Activate
>
> ... can't continue Activate.
>
> open myFile -- (in tell application "Microsoft Excel" block)
>
> ... doesn't understand open message.
>
> Select Worksheet "Glucose" -- (in tell application "Microsoft Excel" block)
>
> .. doesn't understand select message.
>
> Has Excel 2004 changed that much or am I just missing something here?
>
No, you're not missing anything. Excel's AppleScript dictionary has changed
100%. It's the underlying «raw codes» that have all changed, even where many
of the same classes and commands have equivalents that even appear _almost_
the same in English, but are lowercase and separate words now. It's why if
you open any scripts you compiled and saved for Excel X while Excel 2004 is
open, you will see only strange and incomprehensible «raw codes».
To see what the current dictionary looks like, just open it - it's immense.
You should also get the Excel AppleScript Reference from
<http://www.microsoft.com/mac/> , follow links to
Resources/Developer/AppleScript. It explains how the scripring works, in
detail.
To convert your old X scripts to 2004, you are better off re-saving them as
Text, not as compiled scripts, and then making adjustments and re-compiling
and saving. The current dictionary's English terms are usually pretty
similar - things like 'Activate', 'Worksheet', and 'Cell' will re-compile
(to 'activate', 'worksheet' and 'cell') without any adjustment needed while
some others such as 'FillDown' are easily recognizable as 'fill down'. But
in many cases the syntax will be different.)
Since script editors retain the dictionary of the version of an application
first accessed for their whole session, you have to quit Script Editor (or
whatever editor you're using) between versions. Do it like this:
1) Quit Script Editor.
2) Quit Excel 2004 if it's open.
3) Launch Excel X.
4) Launch Script Editor.
5) Make duplicates, in the Finder, of all your Excel X scripts.
6) Open them in Script Editor.
7) One by one, save these duplicates As Text in SE. (Allow the .applescript
extension to be added.) Save and close.
8) Quit Excel X.
9) Quit Script Editor.
10) Launch Excel 2004.
11) Open Script Editor.
12) Open the .applescript Text script files.
13) Make adjustments to the scripts according to the new Excel 2004
dictionary - easier said than done. In some cases this will just mean
lower-casing (and you can even omit this - the compiler will do it for you)
or separating SquishedUpWords (necssary). In other cases, yo might have to
re-write according to the new syntax.
14) Compile, fix errors, compile, and save As Script or As Application.
These scripts will now work in Excel 2004.
--
Paul Berkowitz
_______________________________________________
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