Suppose you are only scripting Microsoft Office 2004 applications for
the Macintosh (OSX). If you were to write the "same script" in Visual
Basic and in Applescript -- that is, follow the same logic and apply
similar commands and perform the same loops -- would one execute faster
than the other? If so, which is faster? Substantially so?
I'd appreciate comments from anyone who ever tried to "speed things up"
by switching from one language to the other. What was your experience?
It should not make much difference, but might be a little faster as a VBA
macro because Word itself is running the process. AppleScript is running
from outside - either an AppleScript application ("applet") which has to
launch, or a script running from the system script menu (meaning
"SystemUIServer" is running it.) There's no built-in script menu in Word,
Excel, etc/.If you're asking whether an AppleScript using native 2004
commands or 'do Visual Basic' would be faster, I don't know and I don't
suppose the difference would be very great, but I'd guess that the native
AppleScript would be a little faster. The only time you'd notice any
difference anyway would be in a batch process that repeated the same
functions over and over again - say on 500 or 1000 documents. If you ever do
any tests on this - which is the only way to know for sure - please report
back and let us know - with timings.
Office 2004's AppleScript and VBA each access the same object model at a
deeper level - something called "OLE Automation". Native 2004 AppleScript
does not route itself through VBA first - although 'do Visual Basic' does.
There are some aspects of OLE Automation that have had to be "translated" a
bit for AppleScript (some aspects of 'range', for example) - that might
involve some overhead. On the other hand there are some aspects of VBA which
would have had to be "translated" a bit for the Mac OS which native
AppleScript may be able to access directly. I suspect that the biggest
difference will just be that Word itself (and Excel. PPT) run VBA macros.
Anyway, do let us know if you find any appreciable differences.
--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <
http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <
http://macscripter.net/scriptbuilders/>
Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.
PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.