Consulting

Results 1 to 2 of 2

Thread: To clear TextBoxes in several Slides

  1. #1
    VBAX Newbie
    Joined
    Nov 2007
    Posts
    2
    Location

    To clear TextBoxes in several Slides

    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...

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    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
    Last edited by Aussiebear; 04-28-2023 at 08:05 PM. Reason: Adjusted the code tags
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •