On Writing Macros At Work

For a variety of reasons, I needed to talk to a colleague of mine at work today. He’d needed a document from me yesterday, and I wanted to check and see if that was something that he was going to need on a monthly basis going forward.

Never hurts to check, right?

Well, in the course of the conversation, we got to talking about a series of weekly documents he produces. “It’s the only thing I do on Mondays,” he said. “It takes all day, and it has to be done on Mondays.”

I’d never thought to ask before. “Tell me, what is it you do?”

He opened up a Word document. “See this?” he said. “I have to go through and I have to delete out this, and delete out that, and it’s tedious. Drudge work.”

I thought for a moment. “Can you send me that? And maybe any written instructions you have? I think I can write a Word macro to take care of all that.”


I shrugged. “Let me see what I can do.”

He sent me the files.

I opened up the Word document. I printed off the instructions.

I’ve written a ton of macros for my own personal use at work. Some of the code I’d written there, I realized, would need only minor tweaking to perform the necessary surgery on this Word document — removing codes, deleting certain lines, fixing some broken names.

I started coding. And in about an hour I had something that worked.

It’s a two-step process. The first takes the document and “cleanses” it of unnecessary data. Since that file gets used later, a second macro takes the “cleansed” document and creates a separate document that has had even more data deleted from it. A “family friendly” document, shall we say.

I asked my colleague to come by my cubicle when he had the chance.

I ran the procedure.

He blinked.

“Oh my god,” he said.

It took less than a minute.

Doing the same procedure by hand, it took an hour and a half.

It’s certainly going to take off some of the Monday stress on my colleague.

Sometimes I’m just too good. 🙂

Published by Allyn

A writer, editor, journalist, sometimes coder, occasional historian, and all-around scholar, Allyn Gibson is the writer for Diamond Comic Distributors' monthly PREVIEWS catalog, used by comic book shops and throughout the comics industry, and the editor for its monthly order forms. In his over ten years in the industry, Allyn has interviewed comics creators and pop culture celebrities, covered conventions, analyzed industry revenue trends, and written copy for comics, toys, and other pop culture merchandise. Allyn is also known for his short fiction (including the Star Trek story "Make-Believe,"the Doctor Who short story "The Spindle of Necessity," and the ReDeus story "The Ginger Kid"). Allyn has been blogging regularly with WordPress since 2004.

One thought on “On Writing Macros At Work

  1. Hi, I need your help to write a Macro on Word 2007 document, I have a document (9 pages) and having Last Name and First name around 7 times in this 9 Page document, and if i change once in the first page, it has to change automatically in the remaining places, what do i need to do to do this?

    Please help me with some instructions / code. Thank you so much for your time…

Leave a Reply

Your email address will not be published. Required fields are marked *