Categories
All MacBU

VB to AppleScript

After my posts this past August about the removal of VB from Mac Office 2008, lots of people asked about how to convert VB code into AppleScript. I had always intended to write up a post with some simple examples but never actually found the spare time to do so. However, Paul Berkowitz, along with the help of some other stellar Microsoft MacBU MVPs has written an excellent tutorial with some concrete and very relevent examples of VB macros and their AppleScript equivalents.
MacTech Magazine announced on Wednesday that their upcoming April 2007 issue will contain the entire 150-page book! I saw a slightly-pre-release copy of the book at MacWorld and I think it will be an excellent reference/HowTo for anyone who has created custom solutions in VB for the Mac.
I know this doesn’t address the cross-platform issues surrounding VB but it should give you some ideas of the richness of AppleScript and our support for it in Mac Office 2008.

10 replies on “VB to AppleScript”

Could you possibly publish the opcode format in which VBA is stored in MS Word documents? At least then the user community could attempt to write a parser which would translate into AppleScript.

Mustafa: from what I understand, the problem isn’t in translating code from one language to another; it’s that Office’s VBA and Apple event APIs are not the same, so calls made against the former may not map cleanly to the latter. Writing a translator to convert loops and variables, etc. would be pretty trivial; writing one clever enough to understand and rewrite API calls for a different API would be quite a bit harder.
Back when the VBA thing was first announced I briefly considered developing a potentially cross-platform solution using an existing VB-to-Python source code translator plus appscript-based ‘adaptor’ libraries that wrapped a VBA-style API around Office’s Apple event API, allowing the original API calls to be used unchanged. But I shelved the idea after some consideration for several reasons, including unease about the amount of work involved in creating the adaptor libraries, uncertainty as to whether or not Office users would actually want to use it, and the awareness that such a solution would have a fairly limited lifespan (i.e. only until MS roll out VBA’s successor) in which to recoup the initial implementation and subsequent support costs. (Though FWIW, I suppose if somebody else seriously wanted to have a crack at the problem I’d be happy enough to provide any pointers I could.)

Mac VBA, as I understand, has never had all the functionalities Windows VBA add as far as writing a C/C++ add-ins to use in Excel, Word …
Do you think that making new functions available to Excel and Word will be easier or just possible with AppleScript only ?
What would be the best recipe ?

You’re right. This doesn’s solve crossplatform issues at all even though it is the most critical issue about VBA. What solution do you propose us who need to work on Excel files with VBA that must be shared by both Win/Mac users? Do you force us to buy Parallel, Vista and Office for Win and spend more hundred dollars?

That’s a pity to drop a simple language like VBA.
But if the VBA 2 Applescript Guide is showing real life samples, we will adapt.

Kuso… you don’t need to buy Parallels… there is Bootcamp after all. Of course, that’s the least expensive component.

“Sewer rat might taste like pumpkin pie, but I’ll never know because I’m never going to eat (it).”
I pay for my own copy of Mac Office solely because I’m a financial analyst who lives on Excel for Windows at the office. If I can’t have VBA, there is absolutely no point to upgrading. Since Vista has its problems, and the value proposition for Office 12 for Windows is not THAT compelling, the lack of cross-platform support is probably a deal-breaker for any Office upgrade in our shop.
It wouldn’t matter if this were 2003, but it’s 2007 and every new home computer bought by our employees this year has been an Apple.
After all, there is a great Office product that offers cross-platform compatibility: Office 11.

I am very concerned about how this is going to affect my 600+ mac users. How can I expect this to affect us and how can I best get us prepared. Could you email me to discuss getting our hands on a beta copy of MacOffice-next to test?
I’m very concerned about compatibility with our pc-userbase (at least 600+) as well.
BTW, I have the copy of MacTech that focuses on Applescript.

Jon, you’re welcome to drop me a private email via the Contact Me link on my main page. Given the organization you are with, I believe you should already have a technical account manager with whom you should be working, but we can chat about it.

Leave a Reply

Your email address will not be published.