Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Star Lounger
    Join Date
    Aug 2015
    Posts
    98
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Missing full stops and semicolons at end of paragraphs in Word 2010

    I am trying to quality control some updated house style documents and wondered whether there was a quick way of checking for missing full stops (or semi-colons for lists) at the end of paragraphs or to just highlight the paragraph marks that have no punctuation. Thanks Shelley
    Last edited by Lady-Laughsalot; 2016-03-22 at 07:49.

  2. #2
    WS Lounge VIP mrjimphelps's Avatar
    Join Date
    Dec 2009
    Location
    USA
    Posts
    3,411
    Thanks
    447
    Thanked 406 Times in 378 Posts
    What is a "full stop"?

    If you know exactly what character should (or should not) be in a certain spot, you can do a manual search for those characters. You could also do a Find-and-Replace, to replace the incorrect characters with the correct ones.

  3. #3
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    A full stop is what I call a period. (Like the one at the end of the previous sentence.)

    I do not know how to search for everything except a certain character.

    Turning on display of non-printing formatting marks may help.
    Charles Kyle Kenyon
    Madison, Wisconsin

  4. #4
    WS Lounge VIP mrjimphelps's Avatar
    Join Date
    Dec 2009
    Location
    USA
    Posts
    3,411
    Thanks
    447
    Thanked 406 Times in 378 Posts
    Quote Originally Posted by Charles Kenyon View Post
    A full stop is what I call a period. (Like the one at the end of the previous sentence.)
    I was thinking more along the lines of CR-LF (carriage return - line feed). You could likely search for that, since it is a specifically-defined character string.

    Quote Originally Posted by Charles Kenyon View Post
    I do not know how to search for everything except a certain character.
    I guess I was unclear -- I meant to say search for specific characters, whether they are the ones you want to keep or the ones you want to eliminate.

    Quote Originally Posted by Charles Kenyon View Post
    Ah! Reveal Codes! I've been looking for Reveal Codes for years in Word, and all this time it was right in front of me.

  5. #5
    New Lounger
    Join Date
    Feb 2014
    Posts
    14
    Thanks
    0
    Thanked 1 Time in 1 Post

    Punctuation Fixes

    Hi
    I worked on a series of punctuation fix tools a year or two ago. My focus was to apply and correct punctuation in bulleted lists, especially styles that used ";" or "," and want the second to last line to have "; and" inserted and the last line ending in ".". I found doing this to be a pain, especially when I had to edit the list and then reapply the ",and" rules. With the tool, all you need to do is hit a shortcut key anywhere in the list and the rule format is correctly reapplied to the list - it saves a great deal of low value editing time.

    I don't leave many body text paragraphs without a training "." character. What I do find is that when I use tables to quickly record information, I often forget the "." and may leave an extra blank line at the end of the cell. I developed another tool which adds the "." to cell paragraphs if it is missing, and removes these blank lines for each of the selected cells in a table. This is a real time saver as it can process an entire table in one keystroke.

    In both cases the tools step through each paragraph checking the last character. This isn't as slow as it may sound. One of the challenges is determining the boundaries of a bulleted list so only that list is processed, especially in document with numbered paragraphs. As always, doing this in the context of table cells also has its challenges, because Word uses hidden characters to denote cell boundaries.

    I have added the driving loop for the punctuation fix and table format code below to give some idea of the processing. There are other supporting routines not shown because because there is a lot of exception handling. You can download the full routines for free at DocumentProductivity. There are many other word editing enhancements also available there.

    Code:
    Private Sub wrkPunctFix(iPara As Long, ilastPara As Long, iMethod As Integer)
    '=========================================================================================================================
    'Fixes the punctuation for the paragraph and format type passed
    'Release 09 Aug 2014 Martin Coomber documentproductivity.blogspot.co.nz
    'Deletes trailing and, then deletes any existing punctuation
    'Then adds the punctuation characters required for each rule
    '=========================================================================================================================
        Dim iChar As Integer
        Dim rPara As Range
        Dim sInputVal As String
        Dim bDeleteWrongTerminatingChar As Boolean
        
        Set rPara = ActiveDocument.Paragraphs(iPara).Range
          
        'Process the start of the Para
        If iMethod = 3 Then
           rPara.Characters(1).Select
            If Selection.Range.Case = wdLowerCase _
            Then Selection.Range.Case = wdUpperCase
        End If
        
        'Now process text at the end of the line - works for end table cell too
        iChar = rPara.Characters.Count - 1 'dont process end of para character
        While rPara.Characters(iChar).Text = " "
            rPara.Characters(iChar).Select
            Selection.Delete ' but does not seem to delete the last space in a para
            iChar = iChar - 1 ' Handle blanks at end and table cChars
        Wend
       
        'Delete and
        rPara.Characters(iChar).Select
        Selection.MoveStart Unit:=wdCharacter, Count:=-3
        If Selection.Text = " and" Then
            Selection.Delete Unit:=wdCharacter, Count:=1
            iChar = iChar - 4
        End If
        
        'Delete terminating character
        If InStr(".;, ", rPara.Characters(iChar).Text) > 0 Then
            rPara.Characters(iChar).Select
            Selection.Delete Unit:=wdCharacter, Count:=1
            iChar = iChar - 1
        End If
        
        rPara.Characters(iChar).Select
        Select Case iMethod ' now add characters
            Case 1 ';
                If iPara <> (ilastPara) Then Selection.InsertAfter ";"
                If iPara = (ilastPara - 1) Then Selection.InsertAfter " and"
                If iPara = (ilastPara) Then Selection.InsertAfter "."
            Case 2 ',
                If iPara <> (ilastPara) Then Selection.InsertAfter ","
                If iPara = (ilastPara - 1) Then Selection.InsertAfter " and"
                If iPara = (ilastPara) Then Selection.InsertAfter "."
            Case 3 '.
                Selection.InsertAfter "."
            Case 4 ' on last line only
                If iPara = (ilastPara) Then Selection.InsertAfter "."
        End Select
        
        If iPara = ilastPara Then 'Position cursor at end
            ActiveDocument.Paragraphs(ilastPara).Range.Characters.Last.Previous.Select
            Selection.Collapse Direction:=wdCollapseEnd
        End If
        
    End Sub


    Code:
    ===============================
    Format each cell in a range
    ==============================
    
    For Each cCell In rSelect.Cells
            While wrkCellRemoveTrailingBlankLines(cCell) ' clean up cell
            Wend
            'Skip cells in Row 1 '
            If cCell.ColumnIndex >= iColStart And cCell.ColumnIndex <= iColEnd And cCell.RowIndex > 1 Then
               For Each pPara In cCell.Range.Paragraphs
                    iCnt = iCnt + 1
                    StatusBar = "Smart Format " & iCnt
                   
                    iChar = pPara.Range.Characters.Count - 1 'dont process end of para character
                    If iChar > 0 Then
                        While pPara.Range.Characters(iChar).Text = " "
                            pPara.Range.Characters(iChar).Select
                            Selection.Delete ' but does not seem to delete the last space in a para
                            iChar = iChar - 1 ' Handle blanks at end and table cChars
                        Wend
                    End If
                    If iChar >= 1 Then ' check if not a blank line
                        pPara.Range.Characters(iChar).Select
                        bAddPeriod = True
                        If bAddPeriod And InStr(".:;?!,", Selection.Text) > 0 Then bAddPeriod = False
                        If bAddPeriod And Selection.Range.Bold <> 0 Then bAddPeriod = False
                        If bAddPeriod Then
                            Selection.MoveStart Unit:=wdCharacter, Count:=-2
                            If Selection.Text = " or" Then bAddPeriod = False
                        End If
                        If bAddPeriod Then
                            Selection.MoveStart Unit:=wdCharacter, Count:=-1
                            If Selection.Text = " and" Then bAddPeriod = False
                        End If
                        If bAddPeriod Then Selection.InsertAfter "."
                        ' handle and/or
                    End If ' test for not a blank line
                Next pPara
            End If  'test for skip cols/rows
        Next cCell
        rSelect.Select
    Last edited by Martin@DocProd; 2016-03-23 at 04:06.

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    You could do a wildcard Find, where:
    Find = [!^13.:;\?\!]^13
    This will highlight any paragraph that doesn't end with .:;? or !
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  7. The Following User Says Thank You to macropod For This Useful Post:

    Charles Kenyon (2016-03-23)

  8. #7
    Star Lounger
    Join Date
    Aug 2015
    Posts
    98
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Thank you Macropod, this is probably what I need as I can add this wildcard search to my highlight macro. I have set my highlight macro to show any punctuation missing in pink, digits in yellow and everything else in green (please see the attached document).

    I am trying to insert at the beginning of the macro to first delete white space after paragraphs so that the macro does not highlight any punctuation already present.

    Is there also a way to tell the macro to only highlight if there is one space after a fullstop/question mark and ignore if there are already two spaces.

    The reason for this macro is to perform quality control checks only and not to find and replace anything, only to highlight the mistakes in the documents so I can visually see what is wrong and make a report.

    Code:
    Sub DPU_QAHighlightPunctuation()
    Application.ScreenUpdating = False
    Dim strFnd As String, i As Long
    With ActiveDocument.Range.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Forward = True
      .Wrap = wdFindContinue
      .MatchCase = False
      .MatchWholeWord = True
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False
      .Replacement.Text = "^&"
      .Replacement.Highlight = True
      Options.DefaultHighlightColorIndex = wdYellow
       .MatchWildcards = True
      .Text = "[0-9\[\]^0145^0146^0147^0148]{1,}"
      .Replacement.Text = "^&"
      .Execute Replace:=wdReplaceAll
      .Execute Replace:=wdReplaceAll
     .Text = "[ ]([\,\:\;\.)])"
      .Execute Replace:=wdReplaceAll
        Options.DefaultHighlightColorIndex = wdGreen
       .Text = "([.\?])[  ]"
       .Execute Replace:=wdReplaceAll
       Options.DefaultHighlightColorIndex = wdPink
       .Text = "([!^13.:;\?\!]^13)"
       .Execute Replace:=wdReplaceAll
    End With
     ActiveWindow.View.ShowFieldCodes = True
      With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Highlight = False
        .Text = "^d"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute Replace:=wdReplaceAll
      End With
      ActiveWindow.View.ShowFieldCodes = False
    Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files
    Last edited by Lady-Laughsalot; 2016-03-23 at 07:42.

  9. #8
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    ***

    Ah! Reveal Codes! I've been looking for Reveal Codes for years in Word, and all this time it was right in front of me.
    For more, see Shift+F1 Reveal Formatting.
    Charles Kyle Kenyon
    Madison, Wisconsin

  10. The Following User Says Thank You to Charles Kenyon For This Useful Post:

    mrjimphelps (2016-03-23)

  11. #9
    WS Lounge VIP mrjimphelps's Avatar
    Join Date
    Dec 2009
    Location
    USA
    Posts
    3,411
    Thanks
    447
    Thanked 406 Times in 378 Posts
    Quote Originally Posted by Charles Kenyon View Post
    For more, see Shift+F1 Reveal Formatting.
    Very useful stuff, Charles!

  12. #10
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    Quote Originally Posted by mrjimphelps View Post
    For more, see Shift+F1 Reveal Formatting.

    Very useful stuff, Charles!
    Thank you.
    Charles Kyle Kenyon
    Madison, Wisconsin

  13. #11
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by Lady-Laughsalot View Post
    I am trying to insert at the beginning of the macro to first delete white space after paragraphs so that the macro does not highlight any punctuation already present.

    Is there also a way to tell the macro to only highlight if there is one space after a fullstop/question mark and ignore if there are already two spaces.
    Try:
    Code:
    Sub DPU_QAHighlightPunctuation()
    Application.ScreenUpdating = False
    With ActiveDocument.Range.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Forward = True
      .Format = False
      .Execute
      .Wrap = wdFindContinue
      .MatchWildcards = False
      .Replacement.Highlight = False
      'Delete fields
      ActiveWindow.View.ShowFieldCodes = True
      .Text = "^d"
      .Replacement.Text = ""
      .Execute Replace:=wdReplaceAll
      ActiveWindow.View.ShowFieldCodes = False
      'Highlight digits, square backets & smart quotes
      .Text = "^p^w"
      .Replacement.Text = "^p"
      .Execute Replace:=wdReplaceAll
      .MatchWildcards = True
      .Replacement.Highlight = True
      Options.DefaultHighlightColorIndex = wdYellow
      'Highlight digits, square backets & smart quotes
      .Text = "[0-9\[\]^0145^0146^0147^0148]{1,}"
      .Replacement.Text = "^&"
      .Execute Replace:=wdReplaceAll
      'Highlight spaces followed by punctuation
      .Text = "[^s ]([\,\:\;\.)])"
      .Execute Replace:=wdReplaceAll
      Options.DefaultHighlightColorIndex = wdGreen
      'Highlight punctuation not followed by two ordinary spaces
      .Text = "([.\?])[^s ][! ]"
      .Execute Replace:=wdReplaceAll
      Options.DefaultHighlightColorIndex = wdPink
      'Highlight characters other than paragraph breaks or punctuation followed by a paragraph break
      .Text = "([!^13.:;\?\!]^13)"
      .Execute Replace:=wdReplaceAll
    End With
    Application.ScreenUpdating = True
    End Sub
    PS: You really should comment your code, so you'll know what each part does later on.
    Note: I deleted your final Find/Replace as it doesn't actually do anything.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  14. #12
    Star Lounger
    Join Date
    Aug 2015
    Posts
    98
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Highlight missing punctuation macro

    Hi all, I would like to update my missing punctuation macro further with the following:

    1. ignore paragraphs/headings in bold text;
    2. ignore instances of paragraphs that end with semi-colons and the words 'or' and 'and' e.g. '; or' or '; and'

    Is this at all possible to include in the coding below please. Many thanks

    Code:
    'is there any punctuation missing'
    Options.DefaultHighlightColorIndex = wdPink   
    .Text = "([!^13.:;\?\!]^13)"
       .Execute Replace:=wdReplaceAll

  15. #13
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    It occurs to me that the Grammarly Add-In for Word and Outlook may well provide this functionality as well.
    Charles Kyle Kenyon
    Madison, Wisconsin

  16. #14
    Star Lounger
    Join Date
    Aug 2015
    Posts
    98
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Hi Charles, thanks for the reply but I have absolutely no idea what that means unfortunately - I am not a coder I simply quality control documents for house style and have put together a highlight macro which quickly shows me what is wrong with the document in a variety of colours - the particular bit I'm looking to update is highlighting where missing punctuation is in pink but I want it to ignore any text in bold which are usually clause headings and also when paragraphs end with
    ; or / ; and - thanks Shelley

  17. #15
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    See Grammarly for Office. I am confident it will find most punctuation anomalies.
    Charles Kyle Kenyon
    Madison, Wisconsin

  18. The Following User Says Thank You to Charles Kenyon For This Useful Post:

    Lugh (2016-07-29)

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •