build log · 2022 · 4 min
Making Excel talk to Word so I didn't have to
a class assignment about not copy-pasting grades by hand.
TThe assignment was simple on paper: pull student records out of an Access database, compute some grade statistics, and produce a report. The obvious way to do it was open Access, copy some numbers, paste them into Excel, retype a few into Word, and fix the formatting three times. The obvious way is also how you lose an afternoon to a task that should take ten minutes.
So I didn't do it the obvious way. VBA macros in Excel pulled the records straight from Access, no manual export step in between. A second macro computed the grade statistics directly in the sheet, and a third one reached into Word's object model from inside Excel and built the actual report, formatting and all, with a chart attached.
The tools don't have to be impressive. The repetitive step just has to disappear.
Nothing about this was glamorous. VBA is not a language anyone chooses for fun, and Word's object model documentation reads like it was translated twice. But watching three separate programs hand data to each other with one click, instead of me doing it by hand three times, was disproportionately satisfying for a class assignment.
It's a small project and I know it. But it was the first time I really understood that automation isn't about the tools being impressive, it's about noticing the repetitive step and deciding it doesn't need a human in the loop.
Mobina Tooranisama
written for a class, kept around because it still holds up