PDA

View Full Version : [SOLVED:] How to select shape during slideshow that has specific text in the textbox?



albino_pygmy
08-11-2015, 02:40 AM
I'd like to have a macro where when I click on a shape "TriggerTest" during slideshow, that it will run the code below. I would like it to hide the button after clicked, and then find every shape on the current slide that has text in the textframe "Test" to change the font color from white to black.



Sub TriggerText()
Dim oShp As Shape
i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
ActivePresentation.Slides(i).Shapes("TriggerTest").Visible = False
For Each oShp In ActivePresentation.Slides(i)
With oShp.TextRange
If .Font.Color.RGB = RGB(255, 255, 255) Then
If ActivePresntation.Slides(i).Shapes.TextRange.TextFrame.Text = "Test" Then
.Font.Color.RGB = RGB(0, 0, 0)
End If
End If
End With
Next oShp
End Sub


I'm still fairly new to VBA and would be greatly appreciated if someone could take a look at this and fix my attempt at coding. Thanks!

John Wilson
08-11-2015, 08:54 AM
This should do it but note the button will NOT be visible when you run the show again


Sub TriggerText(trigger As Shape)
Dim oShp As Shape
Dim oSld As Slide
Set oSld = trigger.Parent
For Each oShp In oSld.Shapes
If oShp.HasTextFrame Then
With oShp.TextFrame.TextRange
If .Font.Color.RGB = RGB(255, 255, 255) Then
If .Text = "Test" Then
.Font.Color.RGB = RGB(0, 0, 0)
End If
End If
End With
End If
Next oShp
trigger.Visible = False
End Sub

albino_pygmy
08-11-2015, 08:45 PM
Thanks for the help, John!