PDA

View Full Version : To clear TextBoxes in several Slides



Afonso
11-07-2007, 04:10 AM
Hi, I am a new member in this forum. I am brazilian and my English language knowledge is not so good, but I need help because in Brazil Foruns I don?t have answer about my problem in VBA code to PowerPoint.
The problem is:
I?d like to know how to clear some TextBoxes in several slides using a command in a specific button in a specific Slide or using a button in a userForm above of presentation. Is it possible? Do I need to put names in every TextBox or Can I use the expression "With? Please, Someone here give me a light to follow...

John Wilson
11-13-2007, 04:13 AM
Hi

It's not clear wether you want to clear ALL text boxes or just selected ones. I'm guessing just selected ones.

I would add a tag to the text boxes to clear. This code will add a tag to all selected shapes on one slide.

Sub tagger()
On Error GoTo errhandler
Dim oshp As Shape
Dim i As Integer
For Each oshp In ActiveWindow.Selection.ShapeRange
oshp.Tags.Add "delete", "yes"
Next
Exit Sub
errhandler:
MsgBox "Select some shapes!"
End Sub

This code would then clear ALL shapes that are tagged


Sub zapper()
Dim osld As Slide
Dim oshp As Shape
For Each osld In ActivePresentation.Slides
For i = osld.Shapes.Count To 1 Step -1
Set oshp = osld.Shapes(i)
If oshp.Tags("delete") = "yes" Then oshp.TextFrame.TextRange = ""
Next i
Next osld
End Sub

You might want to add some error traps eg to check that the tagged shape has a textframe


If oshp.HasTextFrame Then
Hope that helps