View Full Version : Quote Hunter


brewt
01-05-2008, 02:34 PM
I have been formatting some particularly bad files, and found something that just bugs me that I couldn't find another solution for. I would come across parts like this:

"She said, "All this Stuff."

or

She said, "All This Stuff.
Finishing her sentence on another line."


Quote marks were wrong. Word grammar checker couldn't spot it, Whitesmoke couldn't spot it, TextSpresso couldn't spot it. Guiguts could indicate quote mark problems, but it does it with line numbers - yuck. And it is darn tedious to have to actually read and proof for that on lots and lots of badly formatted files.

So it took me a while, but I managed to come up with a Word Visual Basic macro that would look for odd numbers of quote marks in a paragraph. It goes through the file from where you put the cursor, and stops on a paragraph with an odd number of double-quote marks. Solves a good percentage of the problem.

3 gotchas: It needs real [ ^p ] paragraphs (not [ ^l ]), I haven't hammered out the goofs caused by blank lines yet, and the end of the file puts it into a loop that one has to Ctrl-Break to get out of. If anyone cares to modify it, feel free.

I claim no responsibility for how it breaks things in your files. And there are other threads to show you how to import it into Word if you haven't done it before.


########################


Sub QuoteHunter()
'
' QuoteHunter Macro
' Macro recorded 12/26/2007 by bjc
'
'To find tedious formatting problems with quote marks.
'
ActiveDocument.UndoClear

Dim NumCharsBefore As Long, NumCharsAfter As Long, CountNoOfReplaces As Long

Top:

ActiveDocument.UndoClear
CountNoOfReplaces = 0
NumCharsBefore = 0
NumCharsAfter = 0
CountSelectionBefore = 0
CountSelectionAfter = 0


Selection.HomeKey Unit:=wdLine
Selection.GoTo What:=wdGoToBookmark, Name:="\Para"
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Extend
Selection.Find.ClearFormatting

CountSelectionBefore = Len(Selection)


With Selection.Find
.ClearFormatting
.Text = """"
.Replacement.ClearFormatting
.Replacement.Text = "~~" '
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False

End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.MoveRight Unit:=wdCharacter, Count:=1


'Get the number of chars AFTER doing Find & Replace
Selection.HomeKey Unit:=wdLine
Selection.GoTo What:=wdGoToBookmark, Name:="\Para"
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
CountSelectionAfter = Len(Selection)

'Calculate of the number of replacements,
CountNoOfReplaces = CountSelectionAfter - CountSelectionBefore

'Undo the replace
ActiveDocument.Undo
ActiveDocument.UndoClear

'Determine if the number of quotes is appropriate

If ((CountNoOfReplaces Mod 2) = 0) Then
' is even
Selection.EndKey Unit:=wdLine
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1
GoTo Top

Else
' is odd
Response = MsgBox("Odd Number of Quotes in This Paragraph:" & Str$(CountNoOfReplaces) & " of them.", vbOKOnly)

End If

End Sub



########################



Enjoy.
-bjc

carld
01-05-2008, 06:43 PM
I can't tell for certain without seeing the original text but if a speaker's dialogue continues for more than one paragraph then a single quote is appropriate. The closing quote isn't included until the speaker is finished.

JSWolf
01-05-2008, 06:48 PM
I can't tell for certain without seeing the original text but if a speaker's dialogue continues for more than one paragraph then a single quote is appropriate. The closing quote isn't included until the speaker is finished.
I've recently started seeing that, And while I thought it might have been an error, I did look it up to find it's actually correct.

brewt
01-05-2008, 08:02 PM
I've recently started seeing that, And while I thought it might have been an error, I did look it up to find it's actually correct.

I looked it up today, too. Chicago Style says that if the quote marks are used conversationally, a carriage return is another indicator that the speaker has stopped speaking, and is preferred.


By Example:
John said, "I have a lot of stuff that to say.
I have even more stuff to say." Mary replied, "Oh, John, you talk too much".

is not as good as
John said, "I have a lot of stuff that to say. I have even more stuff to say."
Mary replied, "Oh, John, you talk too much".


The 2nd is preferred for short quippy conversations. Sure, if the speaker carries on a great length, one can justify fewer quote marks, but it is preferred to keep the paragraphs of the speech in quotes, if possible.

It is technically correct if an author is quoting someone else at length to have paragraph breaks, within the quote marks - still need one at the beginning of each paragraph.

But if it is conversational,
QuoteMark + speech + QuoteMark + Paragraph
is correct.

Besides, it is for mostly mine own good use, and if anyone doesn't want to be troubled with it, they don't have to be. I'm just trying to correct someone else's lousy formatting to suit myself.

-bjc