Re: How is the applescript support in Office 2004?
Re: How is the applescript support in Office 2004?
- Subject: Re: How is the applescript support in Office 2004?
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 20 May 2004 12:26:01 -0700
On 5/20/04 8:54 AM, "Bill" <email@hidden> wrote:
>
>
In this page, there's a claim that "Microsoft Office 2004 for Mac now
>
offers outstanding AppleScript support"
>
>
<http://www.apple.com/macosx/applications/office/>
>
>
>
Anyone knows the applescriptability of Office 2004?
Yes. Word, Excel and PowerPoint have now been outfitted with complete,
enormous AppleScript dictionaries. It's possible that Word's dictionary is
the largest in existence.
Microsoft decided that they didn't have the capability of maintaining two
utterly different automation object models (VBA and AppleScript). In
essence, that's why the previous Word dictionary became unusable, as it
tried to squish a binary application into a mode that could use the standard
Text Suite designed for single-byte text editors.
So what we've got is something that mirrors the VBA model, which is very
complex. It will be like learning a new language, almost. AppleScript does
_not_ get translated to VBA: AppleScript and VBA are peers which both use
the deeper "OLE Automation" model: it's native AppleScript all right. But
the model has so many parameters per command which in AppleScript of course
does not use descriptive labels. It just runs on. What with all the
enumerations as well (thousands of them) it makes it hard to read,
Microsoft is planning to release a really thorough AppleScript Reference
within a few months. I think most people will find that essential: it's
really hard going without it. Those of you who are used to VBA or 'do Visual
Basic' will know that you can learn how to do things using the Visual Basic
editor. So, until the reference comes out, that's the way you have to do it
still - the terms are almost identical.
But you now get "proper English" lowercase words, no
PortmanteauWordsSquishedTogether like this. And lots and lots has been added
to make it behave like regular AppleScript, not VBA: plurals are lists (not
collection objects), you can get and set a property of plurals, **whose
clauses work** (but you can't get a single property of ;lists using a whose
clause), all objects have a default set of properties (unlike VBA) so you
can 'make new [whatever]' and only specify what you need,
The single greatest benefit over 'do Visual Basic' is that you can now get a
result in the normal way. (With do VBA you had to hope you could write a
string to a text file on your computer which AppleScript could then read:
this only worked for strings and numbers, not for application objects).
The big issue is that Excel AppleScript has also been completely redone
along these lines, with all the terms changed to lower case and the raw
codes changed. So no scripts for Excel X or earlier will work in 2004. On
the other hand, there's a lot more you can do, and it's faster. It also
makes more sense. (Since 'row' is a subclass of 'range', getting the value
of a row is now a list of list, like all other ranges. That's a great
implementation that still works - faster.) I would advise you to save a copy
of your Excel scripts in Excel X or 2001 as text, then open that in 2004 so
you can read it. The changes to the new terms will be easy that way If you
don't save as text, you'll see only unrecognizable deprecated raw codes when
you open the script in 2004.)
There's so much in there, I don't know what more to say. It's very object
oriented, and the closest description I can give is that it's going to be as
difficult to learn as AppleScript Studio is. You have to remember that Word
is not a text editor: instead of setting the content of a document or
paragraph, you'll be wanting to
set content of text object of theDocument to "New text".
You have to get used to that one. And the object model for paragraph differs
greatly form that of word, sentence, etc. But then again, 'paragraph' now
has about a thousand ways of modifying style, format, font, color, size,
etc. etc. It's complicated, and not for the fainthearted. It's a shame
there's not an "easy" way to do these things. But they're all doable. Word
now becomes an app that professionals can script reliably, and others can
probably learn a few tricks to use effectively.
There are probably a fair number of bugs lurking about. Hardly anyone except
Microsoft testers were able to venture in without the reference. (OK, I did
some testing too.) Please report them to MS and/or here and I'll pass them
on. They're committed to fixing any bugs and getting this to work well.
Take a look at the three dictionaries for Word, Excel and PowerPoint, and to
try to imagine how much work this involved. I can't begin to estimate it
myself.
Enough for now.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.