Mobileread
Word macro to check missing quotation marks
#1  Leonatus 07-24-2019, 11:32 AM
Usually, I apply Toxaris' "Check Dialogue" tool to check for missing Quotation marks. That is really great - when it works. Unfortunately, on one of my Computers it doesn't work at all for doubtful reasons. So, I thought by myself, it would be good to have a Word macro that could do this.

In the Internet, I found one that highlights all paragraphs with mismatching Quotation marks. It is this one:
Code
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
Unfortunately, it works, as I understood, for so called curly quotes. I'm working preferably with double angle quotation marks (»...«), Chr (187) resp. Chr (171). Whatever I tried, but I didn't get the macro working for this.
As I'm no technician, it would be of no sense to study programming VBA only for this purpose. Is there Perhaps someone who could provide us with a suiting macro of this sort? That would be very helpful.
Reply 

#2  Doitsu 07-25-2019, 04:31 AM
Have you tried changing the following section:

Code
 If Mid(sRaw, J, 1) = Chr(147) Then iSmart = iSmart + 1 End If If Mid(sRaw, J, 1) = Chr(148) Then
to:

Code
 If Mid(sRaw, J, 1) = Chr(187) Then iSmart = iSmart + 1 End If If Mid(sRaw, J, 1) = Chr(171) Then
for guillemets (»...«)?
Reply 

#3  Leonatus 07-25-2019, 04:41 AM
Yes, that has been my initial reasoning, but it didn't work. I thought it had probably to do with the Chr(34) in
Code
If Mid(sRaw, J, 1) = Chr(34) Then If iNorm > 0 Then iNorm = iNorm - 1 Else iNorm = iNorm + 1 End If
,
but I didn't find a way out.
Reply 

#4  Doitsu 07-25-2019, 05:03 AM
Quote Leonatus
Yes, that has been my initial reasoning, but it didn't work. I thought it had probably to do with the Chr(34) in
Code
If Mid(sRaw, J, 1) = Chr(34) Then If iNorm > 0 Then iNorm = iNorm - 1 Else iNorm = iNorm + 1 End If
,
but I didn't find a way out.
That section searches for dumb quotes ("...") and shouldn't have any effect on the following section. Maybe there's a problem with MS Word.

Try the modified macro on the machine that works with Toxaris's tool.
Reply 

#5  Leonatus 07-25-2019, 07:23 AM
Quote Doitsu
Try the modified macro on the machine that works with Toxaris's tool.
Hm, that's what I did all the time. Did you try to apply the macro?
Reply 

#6  BetterRed 07-25-2019, 07:19 PM
@Leonatus - the Transtools add-in has some macro's referring to "Frenchdoublequotes". Unfortunately they're 'protected' so you can't Edit or Step through them - but I've found the developers to be helpful when responding to emails ==>> Translator Tools / About TransTools suite

BR
Reply 

#7  Leonatus 07-26-2019, 01:54 AM
@BetterRed: Thank you, this could be helpful.
Unfortunately, I seem to have messed up everything. When I created the thread, the macro at least worked in its original form. After trying this and trying that, now nothing works at all, even with the macros still activated and also Windows' Security Center alerts that some apps don't work correctly now (problem could not be identified, but I suppose it was my playing around). I didn't know that Word macros could have such an impact. It seems I better keep my hands off.
Reply 

#8  Leonatus 07-29-2019, 03:37 AM
Daring as I am, I tried once more (after veryfiying that the error messages were obviously not due to the word macros), and succeeded in running the macro in the original form. Paragraphs with mismatiching opening or closing " quotation marks were highlighted, such as proposed.
then I changed the macro in the way Doitsu had suggested, and the same paragraphs were highlighted. Those which I had assigned with » or « quotation marks were ignored.
That is what had occured in my first trials and why I had created the thread.
Reply 

#9  BetterRed 07-29-2019, 04:23 AM
wrong
Reply 

Today's Posts | Search this Thread | Login | Register