Mass editing with Word Macros

This entry is part 2 of 3 in the series Gesture crutches

Freshen up your writing faster!

So I recently took a fantastic class from the inimitable Margie Lawson. I discovered that some of the editing tasks I view as drudgery are a lot easier to do when they’re assignments in a class. (I love school.)

gesture crutchesOne of these drudgerous tasks was to collect all the sentences that used a number of gesture crutches from the first 50 pages and look for repetition and trends, finding the uses you can cut (you don’t need a nod if someone says yes or just complies, etc.), and freshening up your gestures.

The most time-consuming, drudgerous (it’s a word now, okay?) part was actually finding the sentences, cutting and pasting them into a new document. It took me hours to go through my MS 50 pages at a time. HOURS. Not even a quarter of the way through, I knew I had to do something else.

I needed a macro.

A macro is a bit of code you can use with a program to automate a task. Abby Annis introduced me to macros, and Margie classmate Greg Henry provided a few useful writers’ macros in class. I know lots of great writers who use macros to catch clichés;s, throwaway words (just, really, very, etc.). I wanted to take this a little further.

Why use a macro?

I know (because more than one person has said this to me) this sounds needlessly complex. “Can I just use Find/Search?” you might ask. And more than one person has told me about Word 2010’s navigation panel, which shows your searches, excerpts where the text is found, gives you a use count (which you can do in any version of Word, but I digress), etc.

You are more than welcome to continue using Find-and-Replace. If you’re going to highlight or bold your terms, please use Find All (or Replace All + Formatting).

But here’s the advantages of using the macro:

  • This bit of code pulls the full sentences the term appears in (not just the 15 or so closest words) into a new document.
  • The new document is searchable.
  • The new document is ready to edit.
  • The new document lists the sentences side by side, instead of having to flip back and forth, wait for load times, etc.
  • The new document contains results for all of my terms, so I can find cross-term patterns, repetition and echoes more easily.
  • But most of all, it’s a lot faster & easier. The macro takes three mouse clicks to run over 40 searches, and cut and paste the results into a fresh document. It would take me 1800 mouse clicks just to go through each use of each of my terms. Plus highlighting the sentences and cutting and pasting them into a document for better comparison (instead of relying on my memory and the excerpts in the navigation pane)? Oy.

Can I just say that again? Once you spend 10-15 minutes setting up the macro, it takes less than five mouse clicks to “harvest” the results of 40+ searches (using find all word forms, too!).

If you’d rather click that Find button 1843 times, go for it. But I found that method much more time consuming. Again, it took me hours to get through a quarter of this task. It now takes seconds of effort. If that. The next manuscript? Three clicks. The one after that? Three clicks. The one from the drawer? Three clicks.

That’s the beauty of macros.

The EASY/Non-Techie Way

The immensely helpful Paul Edstein wrote a macro to do this all automatically for you. Download the Excel file he posted (you’ll see a security prompt to enable macros; do enable them). In that workbook, enter the word you want it to look for in A1 of Sheet 1, the next work in A1 of Sheet 2, etc. Put a ‘1’ in B1 if you want to search for ALL word forms (smile/smiling/smiles/smiled, etc.).

The macro runs on a folder rather than individual files, so unless your manuscript is the only Word document in the folder on your computer, you’ll need to make a new folder for it and copy or move the manuscript into that folder before you run the macro.

Again, all you have to do is put the words in the spreadsheet, and run the macro (click Developer > Macro. Named GetData, it will probably be the only one there!). Super easy, super user-friendly!

Read message #8 for a tip on how to edit the macro to include page numbers! (This does get a bit more technical, but it’s really just cut-and-paste!)

The MANUAL Way

I’m part of a family craft blog, and we reeeeally like to do things our own way: no patterns, no instructions. It’s either crafting by Braille, or, as we like to call it “being Wayward.”

I think that bled into this project. Before I saw Paul’s workbook, I spent hours configuring my own macro. To make your own macro, enable macros in Word Options. Check out Abby Annis’s detailed macro instructions for more help (except we won’t be recording this, but entering the code directly).

In the Developer ribbon, click Macros. Type a new name into the text box prompt and click “Create.”

Then cut and paste the below. (Delete the line Sub GrabbingCrutches() or you’ll break it!)

VBA:
Sub GrabbingCrutches() ' ' GrabbingCrutches Macro ' by Jordan McCollum, http://JordanMcCollum.com ' With massive help from http://windowssecrets.com/forums/showthread.php/135517-Macro-to-copy-from-one-document-to-another ' I'm not responsible if this breaks your computer! ' Please don't strip my name off this and redistribute it. Don't use my name for endorsing your project. ' Enjoy! Dim r As Range Dim myword As String Dim ThisDoc As Document Dim OtherDoc As Document MsgBox "Remember to open a new document for the results, and close others!" If Documents.Count <> 2 Then MsgBox "Must have two (and only two!) documents open." Exit Sub End If Set ThisDoc = ActiveDocument If ThisDoc = Documents(1) Then Set OtherDoc = Documents(2) Else Set OtherDoc = Documents(1) End If ' The next bit is the actual search. Cut and paste the code from here to the next green line, and change the word in quotes, to add more terms. myword = "nod" OtherDoc.range.InsertAfter mystring & vbCrLf ThisDoc.Activate Set r = ActiveDocument.Range With r.Find Do While .Execute(FindText:=myword, MatchAllWordForms:=True, Forward:=True) = True r.Expand Unit:=wdSentence r.Copy OtherDoc.range.InsertAfter r.Text OtherDoc.range.InsertAfter r.Information(wdActiveEndPageNumber) & vbCrLf r.Collapse 0 Loop End With OtherDoc.Activate Selection.Collapse 0 Selection.GoTo wdGoToBookmark, , , "\EndOfDoc" Selection.InsertBreak Type:=wdPageBreak ' End of the actual search. Paste the code again below (but before End Sub) and change the word in quotes. End Sub
VBA tags courtesy of www.thecodenet.com

Click Save, and you’re ready to go!

Before you use this, you need to open your manuscript, and another file where you want the sentences to go. (This will probably be a new file.) In your manuscript window, click on Macros, select the name you just gave the macro, and click “Run.” In minutes, every sentence using the words you listed will appear in your new file!

The output file is a little bit messy. I use Find-and-Replace (okay, well, actually another macro) to take out the extra returns and tabs, and I have to separate the sentences by keyword. I’m also trying to find a way to get it to print the page numbers UPDATED 23 July: found the code for both of these last two wishes and updated the code above! If anybody has any more solutions there, I’m open to your help!

EVEN Easier way

Lee Korven reached out (a reeeally long time ago, sorry!!) with this code:

Sub OverusedWords()
' OverusedWords Macro
    Dim r As range
    Dim ThisDoc As Document
    Dim OtherDoc As Document
    ' Set your own word list here
    Dim badWords() As Variant
    badWords = Array("nod", "shrug", "smile", "grin", "beam", "smirk")
' You can add more words in this list, just make sure they have straight double quotes around them and are separated by a comma, and the list ends with the parenthesis
    MsgBox "Remember to open a new document for the results, and close others!"
    If Documents.Count <> 2 Then
        MsgBox "Must have two (and only two!) documents open."
        Exit Sub
    End If
    Set ThisDoc = ActiveDocument
    If ThisDoc = Documents(1) Then
        Set OtherDoc = Documents(2)
    Else
        Set OtherDoc = Documents(1)
    End If
     ' The next bit is the actual search.
     Dim badword As Variant
    For Each badword In badWords
        OtherDoc.range.InsertAfter mystring & vbCrLf
        ThisDoc.Activate
        Set r = ActiveDocument.range
        With r.Find
            Do While .Execute(FindText:=badword, MatchAllWordForms:=True, Forward:=True) = True
                r.Expand Unit:=wdSentence
                r.Copy
                OtherDoc.range.InsertAfter r.Text
                OtherDoc.range.InsertAfter r.Information(wdActiveEndPageNumber) & vbCrLf
                r.Collapse 0
            Loop
        End With
        OtherDoc.Activate
        Selection.Collapse 0
        Selection.GoTo wdGoToBookmark, , , "\EndOfDoc"
        Selection.InsertBreak Type:=wdPageBreak
   Next
End Sub

I haven’t tried this yet, but it’s worked for Lee!

Wait, Now What Do I Do?

To get started, follow Abby Annis’s instructions on enabling macros through Figure 4.

In the Developer tab, click the Macros button.

This will bring up a box. Type in the name for your macro at the top and click the Create button.

This opens Visual Basic. It should have a line at the top reading Sub YOURMACRONAME(), so don’t copy Sub GrabbingCrutches() from the code above (unless you want to paste over it and use my great name). Paste the rest of the text (through End Sub) below the ‘ YOURNAMEMACRO macro line. Make sure there’s only one End Sub at the end of the file.

Now, look at the lines in green. Where it says ‘ The next bit is the actual search. Cut and paste the code from here to the next green line, and change the word in quotes, to add more terms., copy the code between that line and the next green line, and paste it as many times as you want the macro to run. Change the word in the first line in double quotes to the word you want to search for.

And Save!

Now, open your manuscript and a new file, and close everything else. In your manuscript, bring up the Developer ribbon and click Macros. Select your new macro from the list and click Run. Click OK on the reminder message that comes up, and that should do it!

My Word List

Is long. It includes gesture crutches, the most common body parts used in body language and visceral responses, and words to describe how dialogue is delivered.

nod
smile
grin
beam
smirk
laugh
lip
mouth
jaw
brow
eyebrow
eye
face
expression
look
gaze
glance
stare
glare
glower
scowl
face
head
frown
tears
hand
fist
arm
shrug
sigh
breathe
breath
blood
pulse
vein
adrenaline
energy
heart
stomach
gut
lung
chest
rib
ribcage
swallow
tone
voice
pitch
volume

My current manuscript is 275 pages long, and my (double spaced) output file from this macro is 100 pages long. I’m hard at work catching echoes and freshening up my body language. I use other macros to highlight words I overuse, “empty” words, and even sequencing words.

Now you’ve got all your crutches collected—now what? Check out these strategies for editing to the top 10 gesture crutches.

Photo credit: crutches on orange backgroundChristian Guthier

Series NavigationWriting crutches: How to avoid overusing the most common gestures!Fixing the Top 10 Gesture Crutches!

8 thoughts on “Mass editing with Word Macros”

  1. Wow, Jordan. That’s awesome. Thank you very much for that techy info. I’m not sure I’m game to try it, but I know I should. I’m just not very tech savvy. Fabulous list of words to catch as well. Thank you.

    1. Thanks, Bron! When you’re ready, I’d give the Easy Way a try–it seems very user friendly. Just put your words in a spreadsheet and tell it where your manuscript is 🙂 .

  2. Hi Jordan,
    So enjoyed reading your ms in Fab 30! Thanks for the macro instructions. I’m so non-techie I don’t know if I’ll be able to figure it out but I’ll give it a try because I spent well over 70 hours combing my ms in May for the same items and copying them into a master table with page number location in the full ms. Not a task I want to do again. Ever. Now I start the table with the new ms and that’s much easier on me. Just have to remember to make the changes each time I edit the ms, however. 🙂

    1. The Excel option might work well for you. If you want it to return the page number (and I do!), there is one line of code you’d have to add (click edit instead of run in the macro menu), but other than that, it’s pretty easy to set up!

  3. Jordan, this will save hours!

    BTW, does one have to be a logged-in member of the VBA forum to download Paul Edstein’s file? I don’t see a link, only an advisory that I have to have at least 0 or more posts to view the attachment.

    I was hoping to use the EASY/non-techie method. However, I don’t want to join another forum I’ll never visit again just to download the file. (shrugging my shoulders)

    1. Oh, dear, I didn’t realize you’d need to be logged in. Sorry about that! I can totally understand not wanting to sign up for yet another forum (how I feel about a lot of things!).

  4. This is great. I’ve already worked with the code you provided and got fab results. Using the Excel file would cut down on the cut-paste-edit of manually editing the code, but I haven’t a clue how to use the Excel file, finding it to be more teckie (teckie-er) than doing it manually. I mean, I load the file and nothing appears. So I put the words in like you suggested, but them what? Haven’t a clue what “stick your manuscript in its own folder for a minute” means. Thanks anyway.

Comments are closed.