by Allen Wyatt
(last updated November 1, 2014)
David is a writer and he uses Word's spelling, style, and grammar checkers a lot. Sometimes he finds that Word's suggestions, for correcting grammar, are bad and he has learned to ignore them. One thing that he has trouble with is the use of quotation marks around dialogue. Word doesn't recognize if David has left off a quotation mark at the end or beginning of a sentence. He remembers using a word processing program years ago that left green quotation marks on your document to indicate a missing quotation mark. He wonders if Word can be made to recognize missing quotation marks.
There is no way to do this natively within Word. The reason probably boils down to the fact that it is almost impossible to determine where a quote should begin and end. For instance, if you have a paragraph that contains four sentences and you place a quote mark somewhere within that paragraph, how is Word to determine whether that mark designates the beginning or end of a quote? If it is the beginning, how would Word know if the ending mark should be at the end of the sentence, the end of the second sentence, or the end of the paragraph? (The same conundrum occurs if the quote is the ending quote, but the placement perplexity extends to the left instead of the right.)
Combine this potential confusion with the fact that the closing quote mark might not even be in the current paragraph—it could be at the end of some later paragraph when the dialog being marked actually ends.
You could, however, develop a macro that would do at least some elementary checking for you. The following macro jumps to the beginning of the document and searches for the first quote mark. It then examines everything from that character to the end of the paragraph. If you are using non-smart quotes, it basically checks to see if there are an even number of quote marks. If you are using smart quotes, then it checks to see if there is an ending quote for each starting quote. If either condition is found to be false, then the text is highlighted.
Sub MarkUnevenQuotes() Dim sRaw As String Dim iNorm As Integer Dim iSmart As Integer Dim J As Long Selection.HomeKey Unit:=wdStory Application.ScreenUpdating = False Selection.Find.ClearFormatting With Selection.Find .Text = """" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute While Selection.Find.Found Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend sRaw = Selection.Text iNorm = 0 iSmart = 0 For J = 1 To Len(sRaw) If Mid(sRaw, J, 1) = Chr(34) Then If iNorm > 0 Then iNorm = iNorm - 1 Else iNorm = iNorm + 1 End If End If If Mid(sRaw, J, 1) = Chr(147) Then iSmart = iSmart + 1 End If If Mid(sRaw, J, 1) = Chr(148) Then iSmart = iSmart - 1 End If Next J If iNorm > 0 Or iSmart > 0 Then Selection.Range.HighlightColorIndex = wdYellow End If Selection.Collapse Direction:=wdCollapseEnd Selection.Find.Execute Wend Selection.HomeKey Unit:=wdStory Application.ScreenUpdating = True End Sub
When the macro is done, what you end up with is a bunch of text selections highlighted if they need to be visually checked. The macro won't, however, finding ending quotes that are outside the paragraph in which the first quote occurs.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13293) applies to Microsoft Word 2007, 2010, and 2013.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
There are times when you need to repeat a word in a document, but doing so triggers an "error reaction" from Word's spelling ...Discover More
When you have Word do grammar checking on your document, it typically marks everything it considers wrong with the way you ...Discover More
If a word is normally supposed to be lowercase, Word helpfully lets you know if you incorrectly capitalize it. If you really ...Discover More
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.