Coding in VBA is teaching me about framework design

Published on Thursday 08 August 2019 | 2 minute read

Ok so another quick one today, for the personal site. Having a full time job that I have to commute to does really change how much free time I get... (no shit, I here you say).

My new job is great. The people are friendly, everyone pulls together, and for a temping job I couldn't ask for more. What's really super great about it though is that... there's room for coding in it! Yep, as I've found everywhere, people are spending a lot of time doing things that computers could be doing for them, giving the people more time to focus on what people do best - connecting with other people, setting pace and direction, getting inspired and creating, etc.

As it happens, the reason my role has been created is to free up someone to focus on transitioning their work flow over to a system that will automate a lot of things for them. What I'm doing will just speed things up in the short term. I'm coding in VBA - visual basic, the ancient language of Microsoft Excel, Word, and Powerpoint. It's actually pretty cool what you can do with it. My work flow is fairly complex, but it all revolves around creating letters from a range of templates and making sure the right people get a copy. It's exactly what VBA is for. Grab a value from a cell in a spreadsheet, open up the right Word document, put that value in the document, print it, save it: All with one click.

What's tough about it is the language. Unlike my IDE for writing in PHP, nothing autocompletes, you can't write tests (that I know of?), you can't click on a method name to be taken to its definition, and the colour highlighting of the syntax sucks. It reminds me exactly of coding my first website when I was about 12. At that time, everything had to be hand coded letter by letter, and there was no such thing as a separate css file. Not in my world anyway. So with this, I'm doing my best to follow my standard object orientated MVC approach, like Laravel that I usually code in, but man is it difficult.

That difficulty however is what's making me kind of love it. I have to had a really great naming convention and a sharp system of organisation to be able to keep on top of it. I'm really focussing on really small, really simple and reusable methods that I can just string together as another way to make it possible to manage the code base.

I'm sure that to the real veterans of VBA my code is child's play. But I like it, I'm happy with it, and what I really didn't expect but am loving is that I've ended up having this great little taster session in framework design. I can't wait to see what else I learn doing it, and how I can apply that learning.


Day 12 of #100DaysOfCode. Added the post title and type to the document title. Did it TDD. That and this journal entry took 45 minutes.

Made by Ed in Somerset. 2022.