VBA Powerpoint - find HIGHLIGHTED text in shape, then ADD a new text box with ANIMATION effect

Anonymous
2020-05-20T03:02:27+00:00

I have this Powerpoint file. Here the link:

https://drive.google.com/open?id=1JaRrBDOEKkCnxeGHrynwdmhPtaOZ8Y4f

I have turned a MS Word file into Powerpoint file using the instruction in this video:

https://www.youtube.com/watch?v=7oao6EzF08U

I want to unhighlight the text, then add a new text box (Red shape fill and Send behind text) with ANIMATION effect, put it in the position of the unhighlighted text like in the pictures.

Therefore, I can show the correct answer to my students when teaching using PPT.

I have about 100 slides like this but I don't have enough time to do it all manually.

Unfortunately, MS Powerpoint doesn't have Macro Recorder like in MS Word and I also don't know much about VBA code.

Is there any way to use VBA code to solve this problem?

Thanks in advance.

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Anonymous
    2020-05-22T14:50:08+00:00

    I'm assuming you have 365 or 2019 because 206 doesn't support highlights in PPT.

    To the best of my knowledge it is not possible to remove highlights correctly with vba but you could try this code to Add Red Shapes

    Sub AddShape()

    Dim osld As Slide

    Dim oshp As Shape

    Dim oshp2 As Shape

    Dim otr2 As TextRange2

    Dim P As Long

    Dim BL As Long

    Dim BR As Long

    Dim BW As Long

    Dim BH As Long

    Dim ZOP As Long

    For Each osld In ActivePresentation.Slides

    For Each oshp In osld.Shapes

    If oshp.HasTextFrame Then

    If oshp.TextFrame2.HasText Then

    Set otr2 = oshp.TextFrame2.TextRange

    For P = 1 To otr2.Paragraphs.Count

    If otr2.Paragraphs(P).Font.Highlight.RGB <> 0 Then

    BL = otr2.Paragraphs(P).BoundLeft

    BT = otr2.Paragraphs(P).BoundTop

    BW = otr2.Paragraphs(P).BoundWidth

    BH = otr2.Paragraphs(P).BoundHeight

    ZOP = oshp.ZOrderPosition

    End If

    Next P

    End If

    End If

    Next oshp

    If BL>0 Then

    Set oshp2 = osld.Shapes.AddShape(msoShapeRectangle, BL, BT, BW, BH)

    oshp2.Fill.ForeColor.RGB = vbRed

    Do

    oshp2.ZOrder (msoSendBackward)

    Loop Until oshp2.ZOrderPosition < ZOP

    osld.TimeLine.MainSequence.AddEffect oshp2, msoAnimEffectAppear

    End If

    BL=0

    Next osld

    End Sub

    Once done you could kill the highlights by choosing OUTLINE view, select all the text in the outline pane and choose No Highlight color.

    WORK ON A COPY!

    0 comments No comments

6 additional answers

Sort by: Most helpful
  1. Anonymous
    2020-05-22T14:15:51+00:00

    Please explain the role of the highlight. Is this just something you have used to illustrate the issue, or does the highlight actually appear in the process of the student answering the question? How does the student indicate which item they think is the answer?

    The highlighted text is the answer key to the question I prepared in MS Word. But when I convert the MS Word file into Powerpoint, It still keeps the highlighted text. 

    If I unhighlight the text in MS Word, then the Powerpoint after conversion won't have the highlighted text. Then I have to manually add the answer key to each slide. 

    I think If I leave the highlighted text in PPT, there will be a way to detect the highlighted text and use it as a mark to add a textbox behind the answer key. (the textbox will have animation effect to show up when I want to show the answer to the students) 

    If adding a textbox is a difficult task, then could you replace it with a shape like a line to mark the answer key.

    If you still can't understand what I mean, I record a video about what I mean.

    0 comments No comments
  2. Anonymous
    2020-05-27T04:13:52+00:00

    WOAHHHHHHHHH, thank you SO MUCH, sir <3 

    I don't know how to express my gratitude to you right now.

    You just saved me tons of time <3 

    By the way, Is there any ways or any websites that can instruct clearly how to use the VBA in Powerpoint ?? As for Word and Excel, I can use Macro to record the commands, but PPT doesn't have Macro and I think I'm gonna need to use VBA sometime in the future.

    One more time, THANK YOU SO MUCH ❤

    0 comments No comments