My thoughts on VBA

I just wanted to take a breather and mention my general dislike for VBA:

[INDENT]VBA is absolute garbage.
Thank you for your time. Thoughts?

There’s an old saying, “Tis a poor workman who blames his tools”.

Perhaps. Or perhaps it is a wonderfully simple, perhaps too simple, tool for automating office stuff. Hard to know. Why does it suck?

It is wonderful, sometimes, for work automation. Which is exactly what I’m using it for right now, however, its array handling is absolutely horrible.

No simple bumping a string to the end of an already existant array in this language. I would actually be very content with it for the automation pieces I can create with it if it were not for short comings of its arrays.

Have you tried using a collection object instead of an array? I agree with you that VB arrays are pretty limited.

Don’t ask me, I have this weird mental block where I can’t learn “visual” programming. I can hand compile my own x86, z80 and 6502 machine language, and I can’t learn visual programming… Hell I’m old school Borland and I can’t even get Delphi to work without running DCC from the command line (probably why I’m using FPC without Lazarus)… and it’s not the event driven that’s messing me up, I can use OWL, GTK – even make a windows program without any toolkits raw… Something about Visual Programming escapes my comprehension.

Though Visual and Basic? Basic is a cute toy language; you basically have to turn it into not being basic by shoe-horning in concepts from other languages where they don’t actually fit…

Not a good combination IMHO. That all security lies user-side is just the icing on the stupidity cake.

PHP and javascript treat arrays as funny hybrids of arrays, dictionaries, collections and lists. Most statically typed languages treat arrays as fixed-length entities. You want to look at collections.

AFAIK you can get a much better experience in modern version of office. I’d rather be coding in .NET any day.

@deathshadow60: I’m not following the security thing, can you explain?

You can inject VBA scripts – like any other scripting language, into documents that support them and they’ll just run with FULL system access. The only way to prevent them from having full access is for the user to disable scripts altogether. It’s been the bane of security since vb scripts inside documents came along… this is particularly true in Outlook, since running code from untrusted e-mails? That has FULL system-wide access?

It even made it onto the page full of truthiness:

Distributing stuff done in VBA is often a problem, as they don’t work for more knowledgeable users who turn app scripts off in the first place, and will be extremely unlikely to agree to turn them on just for your one little project. At the same time in many offices there are old ‘applications’ built with it that means you can’t turn it off in things like excel, word or access, leaving those systems with gaping security holes you end up having to use other software to plug up.

It’s one of those cute late 90’s ideas before we had truly malicious code out there – and unfortunately thanks to endless legacy in-house crapplets many businesses rely upon, it keeps lumbering forward like the behemoth that just won’t die.

Gotcha. The oulook hole has long since been closed and it is actually pretty hard to get Word to run your own in-house stuff these days. But it definitely was a problem 10 years ago. It was only really dangerous because of the other late 90s ideas of everybody running as Administrator in some context so any exploit could easily be translated into pwnage.

I’d rather not use MS products / languages, but it’s what is readily available at my place of work. Hopefully I will have more tools at my disposal soon!