• Find/Replace Hard Returns in PPT Macros

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Find/Replace Hard Returns in PPT Macros

    Author
    Topic
    #497620

    Dear experts,

    I work for a localization company.
    We deal with PPT/PPTX translation on the daily basis.
    When translating those, we need to import them into one of those CAT software products.

    Yet, here is where we start having issues. Segmentation rules make the CAT separate sentences from those PPTs into separate segments whenever – apart from all – there is a so-called hard return (carriage return/paragraph mark) which we cannot really see in PPTs:(

    Sometimes we receive huge presentations from the client, with up to 200 slides.
    And each slide has several shapes with text that is very often separated by those hard returns (e.g. imagine a star-shaped object with ‘Clent Feedback’ text). In CAT those two words get separated into two different segments, which confuses translators making them think that those are 2 separate independent words, which is not correct.

    So, to avoid this, we have to manually prep those files tripple-clicking each such shape with text.
    If after this tripple-clicking we see that the text gets fully selected, this means we are good to go and there will be no segmentation issues.

    But imagine a person doing this for a 200-pages PPTX with 10-15 text shapes in each of the slides.

    Could you please help me out with 2 VBA scripts for PowerPoint to look for and delete (except for the bullet lists events) those single hard returns in all PPT objects throughout the file subbing them by

    1) a space mark
    2) soft return (this keeps the shape text layout, but lets CAT keep the text in a single segment)

    Also, it would be very helpful if somewhere in the script there was a point where I could manually delimit a page range.

    Your help will be truly appreciated:rolleyes:

    Viewing 2 reply threads
    Author
    Replies
    • #1479098

      I understand this may take a bit of time to put together.
      Whoever comes with a solution to this please PM me and I will reward the person with a humble $25 PayPal donation for a working script.

      Thanks again!

    • #1479164

      Try this macro. It assumes that if there is at least one bullet in the text frame then we don’t change the text at all.

      Code:
      Sub LessParas()
        Dim aSlide As Slide
        Dim aShp As Shape
        
        For Each aSlide In ActivePresentation.Slides
          For Each aShp In aSlide.Shapes
            If aShp.HasTextFrame Then
              With aShp.TextFrame.TextRange
                If .ParagraphFormat.Bullet = msoFalse Then
                  .Text = Replace(.Text, vbCr, " " & Chr(11))
                End If
              End With
            End If
          Next aShp
        Next aSlide
      End Sub

      I’m a little confused on the second ‘helpful’ request. Are you asking to add a text delimiter to separate the slides in terms of the CAT tool? Or are you asking to run the script on a subset of the whole presentation?

      The latter is easy enough if we can get the core working, the former is also potentially possible but we would need to determine how your CAT software works out the ‘order’ of the various text frames positioned on the slide. In principle I would assume that we could insert a text box containing an “end of slide marker” and either send it to the back or the front.

      • #1479240

        Hello Andrew,

        Thank you for your response. I do appreciate it.

        The CAT segmentation rules are rather flexible, but usually it separates text into segments for translation (proper segmentation is needed for translation memory to work efficiently) based on several parameters:

        – Period at the end of the sentence followed by a space mark and a capital letter;
        – Paragraph marks (‘hard returns’ which are usually identified in Word as ^p if we are searching them out in a document) – regardless of the type of the following text (non-cap or cap). Once CAT spots a paragraph mark, it is a sign for it to end a segment and start a new one;
        -Bullet list items, etc.

        This works really great when we have regular text in the document. Whenever we do a prep for CAT import we make sure that the client or whoever created the text did not use hard returns to start a new line in the middle of a sentence or when improperly aligning text in a table, because in that case CAT with process such sentence as two separate segments displaying them in separate segments for the translator – which is not only extremely confusing, but also keeps the vendor busy referring to the source file.

        When we receive a PPT with lots of shapes and text in them, it is literally a nightmare, for we cannot see hard returns (like in Word when activating hidden chars) or search them out. So we have to go shape by shape tripple-clicking the text and checking whether all the lines in a shape get highlighted (this is an indicator that there are no hard returns that divide the text, and it is gets naturally divided inside by means of wrapping).

        Imagine a rectangular shape with text in it:

        CLIENT
        FEEDBACK
        COLLECTION
        PROCEDURES

        -or-

        UNDERSTANDING
        CELLPHONE
        HARDWARE
        LIMITATIONS

        All the words will be considered separate segments/sentences by CAT if after each of them there is a hard return inside a shape used by the client (or OCR software product) for the sake of keeping the original layout. Yet, when they are displayed for the translator after being imported into MemoQ, the translators very often mistakenly think those are separate words rather than semantically and syntactically connected structures. When the source file is not being referred to by the translator (and cross-checking obviously takes a lot of time), we get a lot of issues and negative feedback from the client and/or our QA staff.

        Therefore, I am in a desperate search for a script that could modify text in all such shapes in one go replacing hard (carriage) returns with space marks, yet keeping bullet list hard returns intact.

    • #1479297

      I think I understood your issue the first time and believe the supplied macro does what you requested. Does that macro give you the output you were expecting?

      If you didn’t want a soft return in there then you could drop the ‘& Chr(11)’ from the script.

    Viewing 2 reply threads
    Reply To: Find/Replace Hard Returns in PPT Macros

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

    Your information: