An American Editor

April 21, 2010

It’s the Little Things: Software Redux

Not discussed in my previous articles was Microsoft Word’s built-in macro language, Visual Basic for Applications (VBA). But this resource is exceedingly valuable to an editor. Every editor should at least master using wild cards and should try to learn the fundamentals of writing “simple” VBA macros.

I edit a lot of very long manuscripts — 2,000 to 10,000+ manuscript pages — in the STM (science, technical, and medical) fields. It is not unusual for these manuscripts to have chapters with 300 to 1,500 references, and the one thing I can almost universally rely on is that the references are not in proper form, and are even inconsistent among themselves.

For example, a manuscript I am currently working on has a citation style that looks like this for a journal article:

Surname Initials, Surname Initials. Article title. Journal vol;page-page, year.

In one chapter with nearly 500 references, not a single reference was in that form. The style was all over the place and it is my job to fix it.

Fixing the problems means I can do each reference individually or I can identify patterns and write a macro or use wildcards with Find & Replace. For most editors, the easier solution is to use wildcards with F&R. Using F&R means breaking down the references into their parts. It isn’t possible — at least as far as I have been able to determine — to create a single macro or F&R routine to take care of all of the variations that the authors provide. Consequently, I try to address parts of the problem.

 For example, if the authors have put some of the citations in this form:

26, 1988, 1101-1105.

and I want to change it to this form:

26:1101-1105, 1988.

I make use of wildcards as follows:

Find: ([0-9]@)(, )([0-9]{4})(, )([0-9]@)(-)([0-9]@)(.)

Replace: \1:\5\6\7\4\3\8

Similarly, if the authors have really made it complex by using the citation form

2005, Dec;24(12):2037-042.

which I need to become

24(12):2037-042, 2005.

I use a 2-step wildcard F&R as follows:

1st Find: ([0-9]{4})(, [A-z]@;)

 1st Replace: \1;

 2nd Find: ([0-9]{4})(; @)([0-9]@[(][0-9]@[)]:[0-9]@-[0-9]@)(.)

 2nd Replace: \3, \1\4

Every time I figure out the wildcard F&R, I copy the parameters to a word document that I keep handy for the next chapter. This way I only have to copy and paste and click Replace All. I do have to go through several F&Rs, which will correct most — but not all — of the variations; but it is better to have 90% corrected automatically than to have to do them all manually.

And to address problems where, for example, the authors give the reference author names as AW Smith instead of Smith AW, I write a simple macro that I assign to my keyboard (and my XKeys) to make that reversal:

Sub ReverseAuthorName1()

‘ ReverseAuthorName1 Macro
‘ Macro created 4/7/2010 by Freelance Editorial Services

    Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
    Selection.Cut
    Selection.MoveRight Unit:=wdWord, Count:=1
    Selection.PasteAndFormat (wdPasteDefault)
End Sub

 As you can see, even a simple macro can make life easier and editing more productive. What do you do when an author has added punctuation following the journal name and there isn’t supposed to be any? For example, the author gives you

N Engl J Med. 1998;2:200-210

and the correct form for your client is

N Engl J Med 2:200-210, 1998?

We know how to move the year to the end globally but that doesn’t solve the problem of the punctuation following the journal name. You could modify your wildcard F&R but that won’t remove the punctuation where the rest of the cite doesn’t match the Find parameter. The answer is to write a macro.

Here is the macro I use. It works so I’ve not improved it as I’ve grown more knowledgable about VBA. This macro can be much more simply and efficiently written; it was one of my earliest attempts at macro writing.

Sub RefsRemovePuncAfterJournalName()

‘ Remove Punctuation After Journal Name in References Macro
‘ Macro created 10/7/2004 by Freelance Editorial Services

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = “/, “
        .Replacement.Text = “/,Œ‰”
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchWildCards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    ‘ Replace [number],[space] with [number],[smiley]‰

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = “([0-9])[, ]“
        .Replacement.Text = “\1,” & ChrW(9786) & “‰”
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildCards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    ‘ Replace [space][number] with ¿‰[number]

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ” ([0-9]{4})(;)”
        .Replacement.Text = “¿‰\1\2″
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildCards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    ‘ Replace ,¿ with [space]

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = “,¿”
        .Replacement.Text = ” “
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchWildCards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    ‘ Replace .¿ with [space]

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = “.¿”
        .Replacement.Text = ” “
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchWildCards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    ‘ Replace [smiley] with [space]

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ChrW(9786)
        .Replacement.Text = ” “
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchWildCards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    ‘ Replace ¿, Œ, and ‰ with [space]

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = “[¿Œ‰]“
        .Replacement.Text = ” “
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildCards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = “([A-z]@)(.)(^32)([0-9]@{4})(;)”
        .Replacement.Text = “\1\3\4\5″
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildCards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    ‘ This section resets the wildcards to off

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ”  “
        .Replacement.Text = ” “
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchWildCards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
   
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ”  “
        .Replacement.Text = ” “
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchWildCards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
   
End Sub

The macro looks more complex than it really is. The point is that you, too, can write these macros for your own needs if you make the effort to learn a little VBA. But even if you don’t want to go that far, you need to learn how to use wildcards. The time that wildcards and macros can save you puts money in your pocket. More importantly, it prevents the frustration you encounter when you face a lengthy reference list and discover that not one author-provided reference is in correct form.

I suggest picking up a book on VBA programming and also checking out the information on macros and wildcards found in Microsoft Word for Publishing Professionals by Jack Lyon (available at http://www.editorium.com and through bookstores via ISBN 9781434102362). Jack’s book is one of the best sources for introductory information on macro writing available.

Live, learn, and prosper!

The Rubric Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 1,262 other followers

%d bloggers like this: