324 points · by sancarn · 3y ago · 408 comments
From that end-user direction, solutions emerge. And they're in VBA.
Back in the dark ages, we had a horrible reporting engine in Word VBA that pulled report definitions off a fileshare and cut and pasted bits of templates together and then printed them. Literally there was a computer in the office the IT team hadn't taken back because the guy had quit and we logged it in as one of us and ran that .doc all day to do numerous engineering reports. This was quicker and cheaper than filing a PO for the reporting option on the CAD/CAM software which would have taken at least 18 months, involved consultants and eaten at the project budget.
So when everyone bitches about Excel VBA being used for horrible things, the cause is probably further up the stack.
The other cause is what I call monkey hammer. If you give a monkey a hammer he's going to hit things. Everything looks like a VBA solution when you're a monkey and the only hammer you have is VBA. I am a slightly more evolved primate these days.
--
[0] - Except those creating high-security environments with airgaps and whatnot, but that's a special case.
I think there's even a Lazarus IDE available for every company user who wants to create reliable RAD based software bound to corporateware.
Been at a company that was like this to developers. We couldn't approval to get anything installed, and IT was just plain hostile. They also demanded six months notice for us to get a server that was a copy of an existing computer (we wanted to use it for staging).
I also once built an exe for our internal app in Visual Studio, got a call from IT, they said I had a virus on the computer, requested screen share access, and I watched them navigate to the bin folder and delete the .exe I just built (and just the .exe file).
Had to go through a nice long process to get them to stop doing that. Also they didn't seem to understand that I'm a developer and I develop software for the company.
The problem is, cybersecurity insurances nowadays have that limitation as mandatory for coverage... and for good reason.
But then, the next phase starts: that scripts gets copied over (because Jim wanted to run it too) and modified (Jane has a different VBA version) and expanded (now it does "THIS!" too).
Now it's a 1500 line kludge and they want to unload it, ie pass it over to development for maintenance.
... and THAT should be considered a GOOD THING!
It means you've got a tried and true business case for the application, the requirements capture has already been done, you've got an instant user-base and a very clear bar to jump over. Of course, the application must be able to outperform the old application in every way, or else questions will be raised.
I think it's important to point out that the inception of these excel VBA monstrosities is innocent and pragmatic. An SME has a job to do, they're doing their job, but have a need for a custom tool to help do their job.
It is ALMOST NEVER the case that they should drop what they're doing and engage a SW development team to go through a lengthy VERY expensive process with uncertain outcomes-- all the while still having to do their job. It's much more pragmatic, in many cases, to tackle the problem piece by piece, as need arises, with little spreadsheets, scripts and little databases.
I think complaining about VBA monstrosities is wrong-headed. They should be, in a way, embraced as a starting point for devs-- hopefully BEFORE they become mission-critical to the company, however.
There is no way for the IT customer to negotiate this "correctly". It always leads to the same result.
The problem is IT exists to administer computer systems, not to help business people create or maintain software. This brings the wrong mentality and skillset.
One of them had Excel, Access and played with VBA, and in a couple of weekends had come up with a monstrosity that did just what they wanted. It lasted for years as a major part of their work toolbox until someone wrote a proper app for them in C#.
The Software People get called in when it becomes difficult to maintain the ad hoc solution.
He supposedly can do a days work in fifteen minutes and then just hang out. Their computers are super locked down, can’t install anything, can’t go to any non-whitelisted sites, but they have Excel.
There are also the other stories we don't hear: One of my first jobs involved a very repetitive software task that got boring quickly. I spent four weeks trying to automate it, but eventually had to declare failure[1] and then I had to explain to my boss why I was a month behind on my work that was due in a couple of weeks[2].
I imagine that for every "automated my job and now I can do it in 15 minutes" story there are 15 stories of "I automated my job and now I work just as hard maintaining the automation" and another 50 stories of the "I tried automating my job but failed" kind. Only the first one gets re-told.
[1]: Mainly due to hardware quirks I didn't have the experience and skill to work around.
[2]: This is not a story about how automating something is bad; it's a story about the bad decisions one makes when one is inexperienced!
There are two reasons: 1. They have a specific job with a specific set of duties (think sysadmins, or administrative duties) in a large company or in a state beurocracy. 2. They would rather go home or do something more but they are not permitted: they have metered time in the office and other people would and do shut them down on any initiatives.
To me, a workplace like that is like a kafkaesque nightmare but they seem to be fine with it, or rather, have accepted it. It lets them focus on other things in life outside of work.
A few weeks into the job I completely automated these in python and all I had to do was turn my laptop on in the morning, then off in the evening, and I was done.
They were slower, but they also chit chatted with half the office, went to lunch, etc.
Their jobs consisted of pulling some data from here or there, entering it into excel, sending a few emails, entering some data into another system, printing some checks. All stuff that's easy to automate (you'd probably need more than Excel in this case)
In one of his memoirs, the science fiction author Arthur C. Clarke recalled his days as a young man working for the British bureaucracy (something to do with teacher pensions, as I recall). His particular job involved consolidating huge lists of figures into reports. He observed that the numbers in the reports were rounded to two significant figures, well within the accuracy of his slide rule, and started using the slide rule to do all his work.
He could finish his daily quota before lunch and take every afternoon off.
Although I wasn't in the condition of automating the time required down to N minutes, I can see how this dynamic plays - essentially, BigCo with dysfunctional management, where efficiency doesn't really matter.
We both worked at a tox lab and there are masses of numbers to be reviewed. He strung together 8-10 steps to transform, massage, etc. the data for presentation to mgmt, accounting, etc.
What he found was that most of the time, it all ran fine, but when it didn't he had to spend some of that saved time troubleshooting an issue.
They also added more to his plate, since he no longer needed XX hours to accomplish the data push.
In the end, he was more clever than the last person, but didn't have the 7.75 hours of free time that's often touted.
It may exist, but it's rarer.
This is quite reminiscent of the good old "emacs operating system" paradigm just applied to a different context!
It's really no surprise that VBA remains invaluable to businesses. I've worked with product managers that use VBA to perform absolutely jaw dropping levels of complicated business analysis, even in environments where they have access to other tools and languages, mature build processes etc, because it's the right tool for the job they have at hand.
JScript is deprecated, and is likely to be removed at some point too...
CMD is often blocked on many people's machines due to group policy.
PowerShell is really the only other option other than VBA, as discussed in the article. Only reason I haven't used PowerShell til now is the version was hidiously outdated and didn't even support classes... Of course with PowerShell you can evaluate C# code.
Not entirely correct
https://www.encomputers.com/2018/05/disable-macros-in-micros...
Generally I update them with client-ran JavaScript. I love sharepoint lists for their ease of use to users, but the limitations are pretty rubbish if ever you want to do anything programatically, unless you can figure out how to authenticate (and/or use a library which handles that for you).
A better diffentiating factor would be who developed the macro. If it's built in house by someone merely using it to make their lives easier it's doubtful they inserted malicious code. I guess ideally IT should review the code.
Can you access raw memory from it?
If the answer to either of those is no, then that’s a big difference.
Here's a ransomware incident report from someone opening an Excel document with macros enabled:
https://thedfirreport.com/2023/05/22/icedid-macro-ends-in-no...
One example: a couple years ago I was working with a big hedge fund and one of their data analysts sent me an Excel model he had built and I was tickled to see the .xlsm extension (i.e., VBA code on board).
"Ahh ha", I thought, "Let's see what these macro-recording cowboys have been up to."
There was a lot of VBA inside, all written by this Caltech comp sci data analyst who was a Python superstar. The VBA was for pulling data from a database, putting it on a sheet, building some formulas, and some pretty formatting. There were even a few userforms!
I teased him, "VBA? What else are you guys using over there? A cotton gin and a steam shovel?"
I was startled to hear him heap praise upon Excel and VBA instead of the usual complaints.
He said something that stuck with me, "Excel makes it easy to understand the dependency structure that is implied by computations. If I had done this in Python, I'd be answering questions about it all day long."
VB6 has a pretty big community, and https://twinbasic.com/ has really helped unify VBA and VB6 communities as of late. So it might have a little of a resergence in the dev community.
Just look at the effort and knowhow that went into this VBA function that resolves the local file system path from the https url of workbooks synced to OneDrive/SharePoint:
https://gist.github.com/guwidoe/038398b6be1b16c458365716a921...
Lots of awesome stuff still in the VBA/VB6 community!
VBA is powerful and quick at prototyping/iteration.
I would even venture to say that VB6 was the zenith of CRUD apps
Years ago, I heard that JP Morgan had +20k access databases on their network. The data analysts that make up companies far and wide one day discovered that they hate what they’re doing every day. They investigate the “record macro” button. Some might even find it nifty. They use it again and again. Some may even try to get smart and investigate and get curious of the code that it spat out. Some might even go further and attempt to learn enough to change some things around.
A handful might just learn data structures and algorithms to build out a auth / permission system that mimics Django. Might rebuild the UserForm UI from scratch. Implement markdown, sax parsing, custom scroll bar, logging, games.
The answer is because a data analyst probably got bored of what they’re doing every day.
I don't see it ending anytime soon simply because it is easier to build something somewhat complex inside of Excel and put it on a network share than go through IT to install IDE, build something, and then go through security to deploy it. Not every problem requires a jira project and overly complicated solution.
That said, I am wholeheartedly against large things being built in VBA. A few little scripts to query a cube in one system and combine with data from a table in another based on changing values in a few cells is fine but there is a point where you have to go elsewhere.
Ultimately I am a huge fan of of the Alteryx+Tableau/PowerBI stack for the vast majority of projects, so long as you have the server licenses where things can be automated.
The immediate problems I faced was:
1) The analysts wanted every (CRUD) step to happen within excel - excel was indeed going to be their interface, so I needed something which I could launch from within excel.
2) The IT department refused me to grant command line access
3) The IT department refused me to install non-approved dev tools. To get them approved, would potentially take months.
4) The DB admins weren't too keen on letting me add a new DB to the existing Oracle DB. The IT department weren't too keen on me doing my own DB (see step 3)
Hell, just getting new add-ins to excel requires me to BEG the IT folks. And if I'm lucky, the add-ins will just suddenly appear. Will it take a day? a week? a month? Who knows.
So keeping all those things in mind, my only real alternative was VBA.
In the end I managed to get some permatemp solution up and running, which the analysts use once every two weeks.
Therefore I was stuck with Office too, even though I'm a Linux guy. I got a fair amount of kudos building some real frankensteins for them purely in VBA.
At least partly it was due to being in an environment where other people I worked with were already using VBA. They suggested VBA for the task, and they were able to help me get up to speed with it fairly quickly. And at that point in time I was still young enough to be open to trying new things just for the sake of it, my own opinions were not fully encrusted yet :)
I did dabble in javascript for a simple webapp for one small project, but that was kind of a tangent to what we usually worked on.
I really had to lough when I read the following description of the IBM BPM but this sums up a good part of the issue:
"...while IBM BPM does come with a REST API, this REST API is borderline useless to Technology teams and SMEs
Some REST calls use javascript encoded as strings Others require html embedded in json embedded in xml
Database tables aren’t queried by name but by GUID.
There’s no documentation of which GUID relates to which table/process.*"
Quite a lot of things became so outragedly complex no one outside of the IT bothers to handle these, and sometimes not even inside IT. It started with AJAX where suddenly half of the development effort went into designing frontend code and backend services, which honestly does not even touch the end users automation problem. And it went further downhill afterwards. UIs nowadays look modern but are generally as user hostile as the technology stack used to produce these.In Excel my UI is just "there", I have a nice code generator aka as macro recorder, no IT department questioning my authorization to do something nor does not have time or budget to help me with my business problem.
So VBA is the workaround for users around the IT department. Not perfect, but better than what you would get else.
Nothing has changed. In the last century this also happened and it was called islands of automation. In my bubble back then it was considered a good strategy, let departments first play around, and if they are on to something integrate it.
If there's an xls which has been in regular use for more than 18 months, and it contains macros, then it can be assumed it performs some important role and should be properly documented and checked and could also be rewritten in a "real" language and officially supported. Set up a meeting with whoever made it, and whoever's touched it most. Approach it more like "we're improving your cool thing" than "we're taking away your toys".
The moment IT touches your stuff, your job transforms from solving problems to writing emails and having meetings.
Any change, no matter how trivial, takes dozens of emails, dozens of meetings, and half a year to orchestrate.
If IT wants to help solve more business problems, it needs to fundamentally change its self-concept and purpose away from "prevent hypothetical bad things from happening at all costs" and move it towards "solve more business problems".
They exist because they work. You want UX or business analysis? You literally just got that done for you for free if you run into a Excel/VBA application. The hardest part of dev is figuring out requirements, so stop looking at these as toys and start realizing that shadow IT exists because of a gap in development. Full stop. You can argue all day long that you're working your assess off, and you do great products, but the existence of these apps is empirical proof that IT has missed the boat on developing something of importance.
Use that.
Many years ago a company I worked for used to send out a spreadsheet to its suppliers which they would complete with the products they offered and then when it was received back there was a button in the spreadsheet that would automatically upload the data to a central database.
When I first saw this I was curious how it worked and did a bit of investigation - turns out there was VBA behind the button that established the database connection and uploaded the data. What was amusing was that the user had hardcoded the database connection string including username and password. Of course this wouldn't work outside of the firewall - but I'd be careful about letting people get too crazy.
Funny how with computerized process, IT departments are effectively central planners. The lowly workers get to only do what the IT secretariat allows. It is this way because national^Wcorporate security!
Even though it's a visual environment, everything is strongly text based, from HTML to CSS to JSON payloads.
Example: Imagine a CI/CD pipelines using notebooks.
I hate Jenkins/Hudson style build systems so much I could just spit. I just want to run a shell script.
(Alas, I haven't had the gumption to try this idea out yet. Soon.)
Don't get me wrong: I'm not bothered at all when a couple analysts get together and hack away at their own little tools in VBA. Kudos to them for getting into the spirit of things, and maybe they will understand my day to day better as a result.
What does bother me, is when these analysts suddenly expect my systems architecture to somehow accomodate their private projects in whatever capacity. When I ask for documentation (there isn't any), an architectural overview (nope), or even access to the repo for that abomination (access to a what now?).
Because, why shouldn't their spreadsheet inject data into my processing pipeline? Why shouldn't I write a controller that accomodates whatever tidbits of REST they bothered to watch half a youtube video about? When suddenly I get asked this in a meeting: "What do you mean we need authentication? Why does IT always have to make things so complicated?!?".
So yeah, please, people should absolutely build their VBA, lowcode or whatever tools. I do the same thing, the only difference is, I call them shellscripts, and they live in git repo.
But same as I don't let my CLI tools lose on the production server, I won't let it happen with things that have never even been through one code review.
The "Circle of IT" is real. Small companies start out nimble, but then stuff gets crazy and someone decides to standardize it all under one department. This works for awhile, but eventually this organization becomes so useless that it can't serve any functions of the business anymore, so a shadow IT group is built that the business SMEs love as they just "get stuff done". This works for several years, but the executives in IT hate this "rogue" group as it is a constant reminder of their incompetence. Eventually they re-absorb this group and crush them with beauracracy until it all starts again.
Not saying that isn't normal (been there, done that... thanks FINRA), but that's the reason.
I am not here to talk about management-bureaucracy, of which IT depts; same as all other branches one can find in established corporate culture, have more than enough.
I am talking about the perceived "bureaucracy" of us tech guys here, aka. following established procedures to ensure smooth running of mission critical systems.
Yes, I want things to run through code reviews. Why? Because these things go to a production system that our customers (and thus the companies income) depend on. Yes, I want authentication standards. Why? Because there are a gazillion cryptolockers, and worse, out there, who would love nothing more than to run rampant on a nice and juicy production database.
Without shadowing it, I couldn't get anything done. I have to install new (open source) software or packages more or less every day, but IT would expect me to wait for a week for some bureaucracy for each package. IT fights me getting a computer with a specific GPU although it is required to use a library that I need. IT forces a reboot of my laptop in a middle of a conference presentation. IT blocks me from sending Python source code files over email. IT makes my computer boot to take ten minutes. IT forces me to use OneDrive that often simply doesn't work.
Maybe the abomination is not the private projects? Maybe it's the systems architecture?
Also happens to me. OneDrive sucks. It can't even generate proper zip files. Any zip files over 2GB or so I download from it shows as corrupted when I try to extract under linux. IIRC is because OneDrive puts some invalid flags in the files.
That is very true. And part of that service is to ensure that things run smoothly, securely and according to industry standards.
How well would an IT guy provide that service if he were to let some unvetted, undocumented script hacked together by someone who isn't a professional software engineer, run its merry way across the production database?
Did someone give the analysts access to a repo?
Because I'd hazard ~80% of the companies I've seen don't allow "non-development" users access to the corporate version control system.
And not to make too big a deal out of it, but using github, gitlab or anything along these lines, is mostly free, not exactly rocket science, and private repos exist.
You wouldn’t ignore an excel produced by a competent ceo or cfo (those that know all the shortcuts), so why, instead of helping ppl refactor and release their work properly, you gaslight them as incompetent just because they are not IT?
As if any of those were present in the average web project lol. I complained about those points in sprint review this morning, and this is a big project made by IT companies.
It shouldn't be a spreadsheet. The IT departments should democratise the tools which devs use, so even end-users can use modern tools for the job at hand. Then popping a user-made tool into your processing pipeline would be fair enough, and code can be collaboratively maintained. In the end, just as IT wouldn't want SMEs making changes without their knowledge, SMEs wouldn't want IT changing their core system without their knowledge either.
In my opinion, the more people who know and understand the core systems, the better.
Edit: for what it's worth, I do use github (https://github.com/sancarn/stdVBA), but you won't see nearly any versions of any corporate codebases, why? Git doesn't work great with VBA spreadsheets at all. I'm not going through a 10 step process to upload the updated file to the github repo every time I update a macro in a spreadsheet. This is why on-board git is important.
If they want to play with whatever tech tools to get their job done, have at it. They can ask for help when they really need it.
But if they are taking short cuts with the security of the data, that needs to be cracked down on immediately, as they are putting the entire company in jeopardy.
Securing some data is very important. Some data indeed shouldn't exist in the first place. But for a lot of data it matters very little. Most security breaches have rather mild consequences.
Treating all data as megatopsecret and all security breaches as end of the company produces not only unproductive systems, but bad security.
I was hired by the head of Market Risk Management, whose job was to make sure the bank didn't lose too much money on any given day. He hired me because he did not trust the officially approved IT department to write the code to implement his algorithms. One example: they got something wrong because they did not understand mathematical precedence operations, like multiplication over addition.
So one need was to get all the trades as input to the market risk calculations. This was early 2000s, and I installed Apache with Perl CGI on a PC under the desk, and created a little app for the traders to enter trades and track their positions. The traders started favoring this to the official IT solution because it was easier to use and see their positions.
All of this to say, yes, figuring out how to bypass IT is an important function in a lot of corporate environments.
And back to Excel: the traders used it for all of their calculations and simulations. We tried to work with them by giving them tools that plugged into Excel so they could leverage it along with what they were already doing.
This is probably one of the best ideas out there. If companies built a bunch of Excel Addins to leverage business systems, that would be revolutionary for many businesses.
> It is supposedly “Against the technology strategic vision of the company” to allow “end-users” access to high level programming languages.
This is where the idea of "a computer as a bicycle for the mind" died.
A project I work on has some processes that I need to run that can only be initiated through the Azure DevOps Pipeline interface, and these need a "worker agent" on a VM or something, and there is only one worker agent, and some of the jobs take half an hour or more.
So the effective outcome is that despite every member of the team having a full multi-tasking computer on our desk (A multi-tasking computer each! Sometimes more than one each! Plus loads of cloud VMs), we can only run a single task at a time between us and we have to coordinate scheduling manually.
Is this the future?
It is like this because the process involves "secrets" that are meant to be hidden from the team but are accessible to the program when running inside the Pipeline. If it weren't for this secret-hiding, I could just run the process manually on whatever computer I want.
And the secret-hiding doesn't even really work, because I can freely commit code to personal branches on the repository that the Pipeline runs from, and I can run the Pipeline on whatever branch I want, so I could commit a program that prints out the secrets. Ah, but Microsoft has thought of this: if any of the secrets appears in the output, they get replaced with "***".
(Let's skip the part where this accidentally leaks a "secret" username, where I know a particular piece of text that should be output but instead all I see is stars...)
The secret-hiding doesn't work because I can just make the program output base64 of the secret. I don't do this because I don't want to start pasting secrets around in places they shouldn't be available, but it is sometimes tempting.
Anyway, welcome to the future of computing. Thanks for listening to my TED talk.
Imagine for a moment that someone in accounting built a system in lisp to automate part of his job. As time goes on, he takes on more responsibility, which he writes more lisp for.
One day, he gets hit by a bus.
The lisp program he wrote is now an integral part of the running of the accounting department simply by accumulation and momentum, with tons of business logic baked in. Where do you look to find a replacement?
With VBA, there's a much higher chance of an accountant being familiar with the language, and a much smaller surface area for what they can do.
IMO, companies should have a language of choice which is actively encouraged to be used by everyone for all automation needs. Different departments build libraries to automate aspects of their jobs and other departments can use them if needed. I.E. it becomes yet another tool, just like Excel.
I work in security and can't relate to banning Python & replacing it with Microsoft crap either.
Because it is the only programming language Corporate can’t choose not to install.
The wonders of ‘Enterprise’, it amazes me when people bring it up as if it’s any kind of advantage or excuse.
Who wouldn't want to spend a tiny fraction of the effort to get 80% of the outcome?
Then we can write programs in Go/Rust/etc and run them in office or wherever.
VBA is to corporate environments what JavaScript is to the web.
I have already built my own code interpreter in VBA to make Lambda syntax possible: https://github.com/sancarn/stdVBA/blob/master/src/stdLambda.... so I know it's definitely possible, just haven't figured out WASM yet...
My main issue is that unlike VBA, I can't program it from right there in Excel. Sometimes I don't want to start up a full-fledged add-in project that's meant to be reused. I just want to run a quick-and-dirty script once to fix something right now. I discovered Script Lab (https://learn.microsoft.com/en-us/office/dev/add-ins/overvie...) while writing this, so maybe that'd help.
Yeah, that's pretty much a deal-breaker. On top of the obvious thing: can "add-ins" be installed by unprivileged users, without involving the IT department? Can they be embedded in the spreadsheets? A "no" to the former is a real deal-breaker, but a "no" to the latter also hurts adoption. Nice thing about Macros and VBA is that, security settings notwithstanding, every instance of Excel is capable of running them out-of-the-box, without making the user install anything extra.
Microsoft Script-lab will allow you to do just that. https://www.microsoft.com/en-us/garage/profiles/script-lab/
The other issue: it is not trivial to share an addin to end users. You need to publish it to marketplace or sharepoint. Sideloading requires SMB server and GPO. However there is an option that is not mentioned anywhere: it is possible to embed it in a document and it will install when it is open for the first time (after user confirmation).
Edit: Another big issue with OfficeJS is you need to be able to host a web server. That's not usually something most end users have access to...
Any tool with a good ecosystem (tools/libraries/integrations) which allows you to get real work done is useful.
Visual Basic as a desktop app development system (or MS Access which added DB benefits) was very useful in a large number of scenarios. And when you outgrew that, you must have had enough money to pay to scale up to a "real" solution.
Without a doubt, a HUGE TON of money has been made using VBA based systems.
From my own experience (as a mostly-outsider finance dev), my biggest Excel/VBA rewrite was for a company that made $$$$ before, during, and after 2008 doing credit default swaps. Sure the Excel workbook took 5 minutes to open (before I rebuilt it), but VBA was doing a lot of heavy lifting. And the people with the knowledge were making big bucks for the company and themselves with bonuses.
This is really a lesson. Whether the tools are ideal or not, what matters more is if they are accessible to people not specifically trained to use such tools. Again, that's why Python has become #1 outside the client web browser. It doesn't mean the tools are the best, but it means they do the job and are accessible.
But even that isn't why it's popular. It has the most robust data science tools available which has created a steamroller effect and decent web frameworks in Django and Flask.
Python has also replaced Java as "the first learning language" at many universities.
So there are many reasons for it's rise in popularity. VBA not so much.
Python is pretty and I say using spaces beats using curly brackets, begin/end or if/else or other block marking strategies
Experience is also knowing that pretty or not has some subjective component to it
VBA evolved in "harsh" conditions, which kind of explains some of its weirdness though.
It's full of bizarre quirks, like <i>control characters in code</i> that are localized.[1][2] Want your code to run on non-English installations? Better dynamically build all of the strings that are passed to that type of function using placeholders like Application.International(xlDecimalSeparator), making your code much less readable. When code breaks for this reason, it does so with incredibly unhelpful errors, and it is literally impossible for the developer to reproduce unless they know it's a potential problem with VBA, and then they have to switch their interface language to one they potentially don't even know to reproduce the problem.
In Word, at least, probably half of the most useful functions (insert a paragraph after the current one, etc.) will break if you use them on the last paragraph in a table cell, requiring tons of spaghetti-code workarounds.
Want to pass around a string of text that contains multiple formats, the equivalent of referring to the innerHtml property of a DOM element? Good luck with that, unless you want to do it all using hacky scripted-select and copy/paste.
Someone in a parallel thread compared it to Bash, and I actually agree with that. No one should be writing anything complicated in either language.
[1] https://stackoverflow.com/questions/20652409/using-vba-to-de...
[2] https://stackoverflow.com/questions/29832281/vba-range-funct...
VBA in my experience has too many quirks that can't be wrapped in a less-quirky general purpose function. For example, I was just working in Word and was reminded that as soon as tables come into the mix, the order of text in the document is no longer linear in terms of numeric range values. E.g. text might have a greater numeric offset value in the document than text that visually appears after it, if the first text is inside a table. I've had Word VBA get confused about this, and extend a search loop outside the range I gave it to search within and start returning content in other parts of the document. Why would I trust a language like that for anything important?
MS should really have just gone forward with a .NET replacement, IMO. C# is one of the best things they've ever invented.
VBA gives users options. If you want a straitjacketed 1990s predeclared OOP language, you can use Option Strict and Option Explicit and forbid Goto statements and On Error statement. If you can deal with ambiguity, you don't need to.
And of course even a a language with misfeatures is better than the VP of the IT Dev Silo giving you the choice of spending $2m and a year or doing your work by hand.
Also so many people fail to understand why the spreadsheet is so convenient to end users, and as a result of this failure - provide sub-par UIs which actually make thing more difficult, not easier.
Sometimes one has to make a step back and understand that grannies did things right, even though they didn't have graphical UI - business was still running back in these early days, and actually what businesses need for most of the time is tabular view with options to do reactive functional calculations on top of it. Ask your SME friend and he'll confirm it.
I looked it up -- VBA=Visual Basic for Applications.
And speaking of HTML, there was also VBScript, which for me is inextricably linked to classic ASP.
- you have to buy it and justify the expense, but your company already pays for Excel - if it's FOSS, then your cybersecurity will want to scan it and demand you fix every single "critical" CVE, but they don't dare block the use of Excel - you have to run it on a server, so you need to buy a server as well, but Excel runs on desktop machines and you probably already have a network share, too - the server will probably be locked down tight and have no access to other servers, while Excel running on desktop machines has the level of access of the user running it - the IT will try to lock down the server-side installation and grant you as little rights as possible (please submit an enhancement ticket if you need to change the data type of the column), but they can't tell you what you can't do in VBA
I'm not an SME, I work in IT myself, but the amount of self-inflicted hurdles in modern enterprises is staggering. I run a large team that develops ETL jobs, and I needed a database to cross-reference tickets vs jobs vs source systems vs releases vs subteams, because of course no existing system knows all this. Ended up running this in Excel with some Powershell scripts: one to scrape JIRA, another to scrape Airflow, the other to access the target database under my personal account and download the list of tables. Still easier that doing it by the book.
a) I'd be forced to complete a painstaking task "manually", and likely committing the occasional error in the process, not to mention all the time I'd have "wasted"
b) In the case of "optional" tasks (whatever that may mean) I'd have had to give up on whatever functionality/feature VBA enables and some level of detail/sophistication/speed would thereby be lost.
To get a bit more concrete in terms of use cases, any spreadsheet task involving a bill of materials or having to do with stock management is probably ripe for some VBA enhancement. I am aware that it is looked down upon by some, but advising against VBA in favor of Python or some other "proper" tool that calls for an IDE is a bit like telling someone who wants to take up home cooking to get a fancy Japanese chef's knife set plus a sharpener instead of the good old all-purpose knife he is certain to have lying around.
I work in a role that develops air gapped custom communications system, my title is engineer - and to that end I have a broad cross domain knowledge - including traditional system administration tasks. I have to go thru special justification to get local admin to install software our company makes. T
here appears to be a future that will prevent me from using a thumb drive to move our software and configurations from my work PC to our systems - when we ask IT for a solution, they tell us "us the approved file sharing mechanisms" - which are basically limited to OneDrive. On top of all of that, per the written policy, we regularly violate written policy - for example distributing software requires LOB executive permission - which in the context of our larger company would be CEO level - and this is just one glaring example.
IT is either clueless or doesn't care and no one outside of my LOB cares - or is aware - and nothing will change until security policy prevents a major project from delivering on time.
And I know that feeling. I had a job once where if you wanted to install a text editor, not only did you need permission, but someone from IT dept had to come to your desk and install it themselves. And this was at an ordinary mid-sized private company manufacturing nothing special.
All you can do is starve these companies of support, by leaving as soon as you discover such attitudes, and encourage any other devs there to do the same.
But, no, because I otherwise love my job, also where would I go?
From a job security perspective it makes a lot of sense.
That's the “Nobody ever gets fired for buying IBM” idea.
We're doing 'the cloud' wrong, rather than it being a way to leverage BYOD and easier access to information, we're going the opposite way.
I work in a tech company and the IT department is like that. The worst part is that IT/security is separate from the operational branch, and they don't care if it impacts our projects. Even though we are the same company, it seems they only care about their own profits (we get billed), we probably would have better service going to competitors, but we can't (obviously). We lost contracts because of it.
I have a ticket open about MX Resolution failures on outbound email to a certain subset of customers - IT keeps blaming unspecified configuration errors on the customer side, not a misconfiguration in our infrastructure. If they gave me a RCA and told me what was wrong, I'd be happy to go to the customer and tell them what's wrong. They won't do that though, nor will they open up a ticket with our vendor to resolve or investigate the issue on our end.
That's exactly the problem.
Here is a personal anecdote.
Our customer wanted us to setup a development/test machine. Because the software had some real-time constraints, we had to use a CPU with enough physical cores and a customized Linux distribution, accessible through SSH with a remote desktop, it didn't need direct access to neither our corporate network nor the customer network. Essentially, what we needed was a computer with an internet connection and root access for at least one member of the team.
So we setup to talk with the customer to decide on the various requirements. We forwarded them to our an IT security department, and they essentially replied with "this is not a standard configuration, do it yourself". I ended up making the plan myself, had it checked with some guy at the IT security that happened to be cooperative and after a few back-and-forth on some details to make sure it was fine, I started to set up the server. At the same time, my manager made sure we had a spot to put the computer in the server room, all good. We essentially did it all by ourselves, and the customer was ok, I wouldn't say "happy" because all these exchanges with IT security took way too much time. All that was needed was for the IT guy to plug in the machine and configure the network.
Then it went downhill. They first stated that they couldn't let us have our own computers in the server room, only VMs. It was not only completely inadequate due to the real-time requirements, but the price was absurdly high, like hundreds of euros a month. Plus, it is not what they told us earlier.
So, we insisted. They then sent us someone who was probably an architect of some kind and started to suggest some ridiculously complex architectures with a dedicated router, firewalls, etc... when all we really needed was an internet connection with no special privileges (something the customer has already agreed with). Not only it would have cost thousands just for the study, and who knows how much for the actual setup and maintenance, but it came with annoying restrictions.
In the end, we told the customer we couldn't do it, so they did it themselves and we did the dev and tests we had to do on the customer machine. Needless to say, the customer didn't really appreciate the whole affair, and we got dumped.
What we probably should have done, and I have seen it many times is to get a regular consumer-grade DSL/fiber plan just to work around the IT department.
Later, I used to be Django developer, and I think it would be even harder to deploy and maintain.
The only inconvenience I recall was some functions had tedious API, arrays/lists were hard, had to be created like kinda Collection.new(...).
Imagine what people would do if VBA was a better language and had a better IDE that wouldn't scream at you every time it found a syntax error in your code-in-progress.
VBA is built in. That is the reason.
Its the same reason emacs users use elisp.
Good article.
What it doesn't mention is the versatility and value the combination of VBA and the various MS Office applications brings to the table for small and medium businesses.
Translation: VBA, as a tools for SMB's, can make them money.
VBA is often discusses in terms of Excel. However, it is available --and very useful-- across the entire MS Office suite.
Over the years we have used VBA for applications ranging from engineering to business. From automated code generation (generate Verilog FPGA code based on easy-to-maintain data entered into Excel) to financial analysis and projections (example, Bass Diffusion Model product evaluation).
One of the most fun applications I remember was using VBA to create a training application for dealers and customers using PowerPoint. We created a full simulation of this device (control panel with buttons and an LCD display), using VBA to run the show. This was super easy to distribute to our dealers, required no installation and everyone could run it. Of course, today it would make more sense to build such a thing as a web app.
Still, VBA makes such things accessible to lots of people. You can use it with Excel, Word, Access, PowerPoint, etc. As a tool, it is useful and convenient. Most people could not care less about the, often pedantic, opinion us engineering types can have about such things.
As a software engineer I wish something like Python was a first-class citizen across the MS Office suite. I know they are slowly making this happen. I haven't looked into it for a while. It seems MS wants you to have a subscription to Office 360, which is a nonstarter as far as I am concerned. I could be wrong.
There always seemed to be an assumption that you would empower the user with tools.
I suppose VBA does that to an extent, but it seems like we haven't moved the idea forward in 30 years.
I'd like to say it's because it's 'good enough', I suspect it's more a hold over from an earlier time that hasn't been eradicated yet.
Don't get so emotionally invested in tools because they're just tools at the end of the day.
The business doesn't care what tools are used so long as they do their job.
Also, knowing how to navigate a convoluted tooling systems ensures your job security, so why are you complaining again?
Because a job that would take 15 minutes turns into a 3 hour task. It might surprise you but some people actually enjoy their job and ticking off tasks :)
Many of these people do not think about themselves as developers. They have primary responsibilities outside of IT structures which usually means that "more professional" tools are not available to them.
They invested substantial amount of effort to learn the language and are locked into the platform because everything they know about programming, every tip, every trick, every solution to every problem is all about Windows, Excel, VBA, etc. and they would have to essentially start from scratch if they wanted to do anything else like Python.
I do tend to disagree here. It really depends how invested they are with VBA. Many VBA skills are highly transferrable to Python and other high level programming languages.
I was fortunate to have experience with multiple languages from the start, but many of my colleagues have programmed in other languages other than VBA after learning VBA only to begin with. From Ruby to Python and beyond.
1. The development environment is already installed.
2. The platform does a lot. Being able to program using Office components or program using browser components gives the programmer a lot to work with.
3. The platform extends into a "real" programming environment - VBA is a gateway drug to C# and all the other MS developer tools. Just like learning JS in the browser eventually turns into, can use my JS skills for writing other code on my machine?
Programmable platforms have historically been really important to adoption and longevity in the enterprise. The emergence of REST APIs as features on many web apps fills a lot of this gap for SaaS.
Quite a clever solution they use, I thought.
I implemented a simple XOR based encryption in VBA and it worked.
So, I imagine that's just one of many real world business use cases.
I quite enjoyed the bizarre deep dive into VBA and Excel tho
But the functionality is locked to higher tiers of 365 accounts. So I guess VBA is still the king.
Important to note that office apps and Macro-tools were essential before the Web and Mobile apps became popular. Businesses have to carefully balance between Adopting the Newest tech/fad and Growing their business, and Staffing/skills.
Everyone needs to seriously look at DDD again. You want a product?
- Small team composed of a few developers, one or two SMEs, one or two DEVOPS.
- SMEs teach the devs the domain language. Explain requirements in gherkin language or equivalent.
- Devops hand hold the developers to get it into production. (Devops guy can probably be split between 2-3 teams).
Many SMEs want to work their problem, not code. You're helping them.
VBA is anti-technology. There is no version control, there are no tests, automated integration tests? HAH!
*PS: "You build it you own it" Is wrong. You need a small "meta-programming" team that makes sure the teams have the tools they need to own production without their brains exploding. Perhaps these meta-programming teams can be split among a few corporations - as you don't really need them there all the time.
Huh. I distinctly remember working with VBA-based systems like 20 years ago where that was a massive difference - like, I'd been writing code on mid-'90s VB4 and it had "on error goto" but VBA didn't like 10 years later. But maybe it was specific to one or two VBA-based platforms.
Either way, it was super infuriating since it meant the only non-catastrophic error-handling possible was "on error goto next" and then manually checking error codes.
The writing was absolutely on the wall about Notes well before the Y2K panic. Staying on that platform when the world was passing you by, even if you couldn't get exactly the same functions in Outlook/Exchange or whatever else you slotted in, was foolish and honestly constitutes professional malpractice for whomever made that call.
– The IDE is built in.
– The syntax is beginner-friendly.
– It’s stable and doesn’t change every six month.
– It’s well-documented.
– No build steps, it just runs, and fast.
– It’s resource-efficient (CPU, RAM).
– You can easily create dialogs and forms using the built-in visual GUI builder.
– You can break into the built-in debugger from your Office document.
– If you want to get fancy, it has interfaces and classes.
– You can call any win32 function and use any COM object.
- It's what's available.
There is a bit baked into this statement which the article breaks down further:
- Companies won't approve anything else in the hands of ordinary users
- Companies' developers are too busy with too high priority items
And some things not mentioned in the article are also baked in:
- Even when developers get around to a project that could replace VBA, they don't understand the project, underestimate the time and resources required, and deliver a subpar product as a result
- Companies lay off people doing work IT and developers can't be bothered to support with no real plan other than overburdening the remaining ordinary users with extraordinary problems
That's pretty cool.
VBA is terrific for glue code. Back in the day, before the Internet opened up the security hellmouth, ActiveX was pretty great for use cases like yours.
Early '90s, I made an in-house cost estimation app using Access 2000. It'd extract data from our MicroStation (belch!) CAD drawings to generate budgets and bill of materials. Huge time saver.
Here's a modern example:
https://softwareconnect.com/construction-management/planswif...
Cost estimation apps rely on a database of SKUs, assemblies, etc. Every entry can have dependencies, equations, etc. Like "for every 10ft of X, add 1 widget Y".
Super easy to implement with dynamic languages like LISP, where data can be code (macros). Not something Visual Basic is known for. My "one cool trick" was using VBA's built-in "eval" function equivalent.
I ended up leaving about 3 months after it was done but they continued to use it for a few years until it was replaced by a COTS system.
I've run into this quite a bit at my workplace. Some business group writes an app in Excel using VBA + an add-in and it becomes the core part of some workflow. But IT didn't know about it, nor did they know about the (for example) 32-bit ancient Excel add-in that it requires, which then breaks when an Office upgrade happens...
Now IT is stuck where a routine upgrade broke some weird edge case thing and needs to maintain a downlevel version of Office for a small group until they can re-develop their business-critical tool in something else.
Use-known-stuff rules up front -- in this case which may well be VBA -- alleviate a lot of these long-term problems.
I, as an SME, am fully happy coding in C#, Java, Rust, whatever! As long as the language is turin complete, is pro-code and versatile enough, I'm all ready to go.
Do note that IT actively chose to develop the solution in Microsoft PowerApps, despite my advising that the solution would be better suited as a web app.
Otherwise, you're on your own.
- I would not call it fast or resource-efficient, but fast enough and efficient enough for most unsophisticated purposes.
- No red tape for installation, IT cannot (easily) disable it, isn't an extra line item on any bill
VBA seems like a solid choice compared to where they have their data being stored.
There was an attempt at a .net version of VBA (would have worked the same way, with a mini visual studio embedded in Office), called VSTA. But it was killed. So the cattle (business users) is stuck with 1990s technology.
I remember having to deal with it on my first job because the team knew nothing about coding. They had “recorded” macros by clicking around and never seeing a line of code. It was incredibly brittle: any change to the table, even adding a comment, would break it, but it allowed them to automate a task.
In an ideal world this is how first draft of software would be done. And professional software engineers only come in when it's time to make it secure, fast, less brittle, scalable, available to more users, etc.
Like finding the screen that takes forever to load because there's a hidden O(n^2) in there and replacing it with an O(n log n), etc.
People struggle with not knowing how to describe a task they can do but not with code. The record gets you very close very quickly. If you’re fluent in adjusting selection logic you’re usually going to have it pretty easy.
- embedded database via Access Data Objects (ADO).
There's still no modern equivalent. The ADO notion was lost in the transition from workgroup (file sharing) to client/server (ODBC).
ORMs, ActiveRecords, builders (eg JOOQ), templates, etc. are all partial solutions. Abstractions with sharp edges and traps.
(Yes, I'm working on it.)
Huh, fast? Sure, it's fast enough for its use cases, but it is not fast.
VBA is basically the scripting language of Office. It integrates well with Microsoft Office, and in a business environment, pretty much everyone has access to it.
Are there better languages? Sure. However, it is hard to beat the integration and ubiquity.
And, VBA is a much, much better language than (ba)sh script!
If there's a third category, please enlighten me
We have such sights to show you.
It was a bit of a mess indeed, however as the author of the Java port, I would assess the Korn shell scripts were still much better approach, despite the mess.
Reason for the port? Whoever was taking charge of the application wasn't confortable with UNIX and decided having it done in Java was easier for having random external consulting companies develop it further.
And many Linux users whined for many years after that mess was replaced by systemd and many still do.
Exception, not the rule.
Edit: regarding the video embedded in article
The problem is they're an intelligent person falling short of their potential.
As understandable as it is, raging against people around you for their shortcomings isn't going to help you or them. You've got to do the hard and scary work of grinding your way up to get to where you belong.
But like I know that pain. I've been there before. After getting into FAANG there's still plenty of meaningless work but at least the people are smart.