• find/replace with carriage return (ppt xp)

    Author
    Topic
    #390423

    Is there a way to do a find/replace in ppt to find the lines that have on them and delete the plus the line feed or carriage return? The will always appear on a line by itself. thanks

    Viewing 0 reply threads
    Author
    Replies
    • #693537

      Without resorting to VBA, it appears there isn’t a good way to do this and select the “paragraph” character as well. You can do the delete, but unless it’s the last line of the text area, a blank line remains. Fortunately, the Find/Replace doesn’t use wildcard characters, although the VBA version does.

      • #693615

        how would i write a macro in vba to do it? thank you for the help.

        • #693623

          VBA could look like this:

          Sub testClearPara()
          ClearPara strTarget:="$"
          End Sub
           
          Sub ClearPara(strTarget As String)
          ' Replace matching paragraphs with nothing
          Dim sld As Slide, shp As Shape, intCount As Integer, para As TextRange
          For Each sld In ActivePresentation.Slides
              For Each shp In sld.Shapes
                  If shp.HasTextFrame Then
                      If shp.TextFrame.TextRange.Paragraphs.Count > 0 Then
                          ' More than one paragraph; loop backwards
                          For intCount = shp.TextFrame.TextRange.Paragraphs.Count _
                                          To 1 Step -1
                              Set para = shp.TextFrame.TextRange.Paragraphs(intCount)
                              If intCount = shp.TextFrame.TextRange.Paragraphs.Count Then
                                  ' No trailing CR+LF to match; leaves a blank bullet
                                  If para.Text = strTarget Then
                                      para.Delete
                                  End If
                              Else
                                  If para.Text = strTarget & Chr(13) & Chr(10) Then
                                      para.Delete
                                  End If
                              End If
                          Next
                      End If
                  End If
              Next
          Next
          End Sub

          Or maybe there’s a simpler way, but this seems to work okay for identical matches.

          • #708589

            Thank you for this code. It is working fine. It just takes a while to go through the 80 slides. Is there a way i can limit it to just slides 35 to 46? Also, i tried recording a find/replace and no code was generated. I want to search for in slides 1 to 80 and replace it with 2003. Thank you for the help.

            • #708593

              To limit the code to slides 35 to 46, replace

              For Each sld In ActivePresentation.Slides

              by

              Dim i As Integer
              For i = 35 To 46
              Set sld = ActivePresentation.Slides(i)

            • #708595

              yes, that makes sense. thank you

              Do you know the code to search/replace from an excel macro to powerpoint? i tried recording a macro but no code came up in ppt. thanks

            • #708599

              I know nothing about PowerPoint VBA., sorry.

            • #708600

              I know nothing about PowerPoint VBA., sorry.

            • #708991

              > Do you know the code to search/replace from an excel macro to powerpoint?

              You want to search inside a presentation file from inside Excel? Your best bet is to write and debug the code in a PPT first, and then figure out how to run it from Excel. What sometimes happens is that object names exist in both applications’ object models and cause confusion, and those might need to be qualified with the application name. But first see if you can write the code in PPT.

            • #708992

              > Do you know the code to search/replace from an excel macro to powerpoint?

              You want to search inside a presentation file from inside Excel? Your best bet is to write and debug the code in a PPT first, and then figure out how to run it from Excel. What sometimes happens is that object names exist in both applications’ object models and cause confusion, and those might need to be qualified with the application name. But first see if you can write the code in PPT.

            • #708596

              yes, that makes sense. thank you

              Do you know the code to search/replace from an excel macro to powerpoint? i tried recording a macro but no code came up in ppt. thanks

            • #708594

              To limit the code to slides 35 to 46, replace

              For Each sld In ActivePresentation.Slides

              by

              Dim i As Integer
              For i = 35 To 46
              Set sld = ActivePresentation.Slides(i)

          • #708590

            Thank you for this code. It is working fine. It just takes a while to go through the 80 slides. Is there a way i can limit it to just slides 35 to 46? Also, i tried recording a find/replace and no code was generated. I want to search for in slides 1 to 80 and replace it with 2003. Thank you for the help.

    Viewing 0 reply threads
    Reply To: find/replace with carriage return (ppt xp)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: