Link to home
Start Free TrialLog in
Avatar of Arunraj Sekar
Arunraj SekarFlag for India

asked on

Need Vba Code to a find a period which have in end of the bullet points

Hi Expert,

We are working in PowerPoint with huge of slides...

I am trying to check at end of the all bulleted points have Period, colon, Semicolon, and Comma are there or not. if it is there means I need to highlight that one via VBA... (because as per our standards we should not kept any puntuvation at end of the bullet points, this was very painful while doing quality control)

is it possible to do via VBA PowerPoint?
kindly any expert help me...
ASKER CERTIFIED SOLUTION
Avatar of John Wilson
John Wilson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Arunraj Sekar

ASKER

Hi JSRWilson, Thank you very much. This code works well in shape. But this code need to alter which need to check in bullets points only, not in paragraph. and then this code is not work in groupitem and table. kindly help me
Hi Rgonzo1971, your concept is absolutely right. But it shows empty msgbox.. it nothing find in that msg box
Avatar of Rgonzo1971
Rgonzo1971

Could you send a dummy?
This code is just "top of my head" so you will need to test and maybe make some small changes but it should get you on the right track.

Sub chexPunct()
   Dim osld As Slide
   Dim oshp As Shape
   Dim L As Long
   Dim strReport As String
   Dim iRow As Integer
   Dim Icol As Integer
   Dim G As Long
   Dim otr As TextRange
   For Each osld In ActivePresentation.Slides
      For Each oshp In osld.Shapes
         If oshp.Type = msoGroup Then
            For G = 1 To oshp.GroupItems.Count
               If oshp.GroupItems(G).HasTextFrame Then
                  If oshp.GroupItems(G).TextFrame.HasText Then
                     For L = 1 To oshp.GroupItems(G).TextFrame.TextRange.Paragraphs.Count
                        Set otr = oshp.GroupItems(G).TextFrame.TextRange
                        If hasPunct(otr) Then _
                           strReport = strReport & "Slide " & osld.SlideIndex & _
                           " Group " & Chr(34) & oshp.Name & Chr(34) & " has illegal characters in para. " _
                           & L & vbCrLf
                     Next L
                  End If      'TF
               End If      ' text
            Next G
         Else
            If oshp.HasTable Then
               For iRow = 1 To oshp.Table.Rows.Count
                  For Icol = 1 To oshp.Table.Columns.Count
                     If oshp.Table.Cell(iRow, Icol).Shape.HasTextFrame Then
                        If oshp.Table.Cell(iRow, Icol).Shape.TextFrame.HasText Then
                           For L = 1 To oshp.Table.Cell(iRow, Icol).Shape.TextFrame.TextRange.Paragraphs.Count
                              Set otr = oshp.Table.Cell(iRow, Icol).Shape.TextFrame.TextRange.Paragraphs(L)
                              If hasPunct(otr) Then _
                                 strReport = strReport & "Slide " & osld.SlideIndex & _
                                 " Table " & Chr(34) & oshp.Name & Chr(34) & " has illegal characters in para. " _
                                 & L & vbCrLf

                           Next L
                        End If
                     End If
                  Next Icol
               Next iRow
            Else
               If oshp.HasTextFrame Then
                  If oshp.TextFrame.HasText Then
                     For L = 1 To oshp.TextFrame.TextRange.Paragraphs.Count
                        Set otr = oshp.TextFrame.TextRange.Paragraphs(L)
                        If hasPunct(otr) Then _
                           strReport = strReport & "Slide " & osld.SlideIndex & _
                           " Shape " & Chr(34) & oshp.Name & Chr(34) & " has illegal characters in para. " _
                           & L & vbCrLf
                     Next L
                  End If
               End If
            End If      ' not table
         End If      'not group
      Next oshp
   Next osld
   MsgBox strReport
End Sub

Function hasPunct(otr As TextRange) As Boolean
If otr.ParagraphFormat.Bullet.Type <> ppBulletNone Then
   Select Case otr.Words(otr.Words.Count)
   Case Is = ".", ",", ":", ";"
      hasPunct = True
   End Select
   Else
   hasPunct = False
   End If
End Function

Open in new window

I have attached a file with example including a code with required output explained in outside of the slide. kindly look it for clear idea about my question.
Orphan-and-Puntuation.pptx