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.”
“Really?”
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. 🙂
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…