Consulting

Results 1 to 9 of 9

Thread: Clearing Textboxes when slideshow closes (PowerPoint 2010)

  1. #1

    Clearing Textboxes when slideshow closes (PowerPoint 2010)

    Hello,

    I am using PowerPoint 2010, I have been making a PowerPoint that contains Textboxes. When I enter a value into these textboxes the value remains even when the slideshow has been closed.

    How can I get these textboxes to clear when the slideshow closes.

    My brain keeps going for the FormClosing event for Visual Basic but I don't know how to do this in VBA.

    Thanks,

    Joe

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    See if this works for you (it's not completely reliable)

    [VBA]Sub OnSlideShowTerminate(Wn As SlideShowWindow)
    Dim osld As Slide
    Dim oshp As Shape
    On Error Resume Next
    For Each osld In ActivePresentation.Slides
    For Each oshp In osld.Shapes
    If oshp.Type = 12 Then
    If oshp.OLEFormat.ProgID = "Forms.TextBox.1" Then
    oshp.OLEFormat.Object.Text = ""
    End If
    End If
    Next oshp
    Next osld
    End Sub[/VBA]
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    Thanks that helped.

    How about a macro for individual textboxes on slideshow end. As I forgot about one textbox that needs to remain uncleared.

    Thanks,

    Joe

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    You would need some way of identifying it. eg if it's on slide 6

    [vba]Sub OnSlideShowTerminate(Wn As SlideShowWindow)
    Dim osld As Slide
    Dim oshp As Shape
    On Error Resume Next
    For Each osld In ActivePresentation.Slides
    If osld.SlideIndex <> 6 Then
    For Each oshp In osld.Shapes
    If oshp.Type = 12 Then
    If oshp.OLEFormat.ProgID = "Forms.TextBox.1" Then
    oshp.OLEFormat.Object.Text = ""
    End If
    End If
    Next oshp
    End If
    Next osld
    End Sub
    [/vba]
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    I should have made this clear before.

    On slide 4, I have two textboxes. TextBox1 needs to be cleared, TextBox2 needs to be changed to "Correct: 0/3".

    On slide 6, I have three textboxes. TextBox 1 and 3 need to be cleared, TextBox2 needs to be changed to "Correct: 0/4".

    Thanks,

    Joe

  6. #6
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Just set those two back to the text needed.
    [VBA]Sub OnSlideShowTerminate(Wn As SlideShowWindow)
    Dim osld As Slide
    Dim oshp As Shape
    On Error Resume Next
    For Each osld In ActivePresentation.Slides

    For Each oshp In osld.Shapes
    If oshp.Type = 12 Then
    If oshp.OLEFormat.ProgID = "Forms.TextBox.1" Then
    oshp.OLEFormat.Object.Text = ""
    End If
    End If
    Next oshp

    Next osld
    ActivePresentation.Slides(4).Shapes("TextBox2").OLEFormat.Object.Text = "Correct: 0/3"
    ActivePresentation.Slides(6).Shapes("TextBox2").OLEFormat.Object.Text = "Correct: 0/4"
    End Sub[/VBA]
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  7. #7
    Works a treat. Thank you, much appreciated.

    Thanks,

    Joe

  8. #8
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Just so you know we have seen some problems with the onslideshowterminate method. Sometimes it fails to fire after the presentation is saved and reopened. Our experience is it works well if VB has been manually accessed during the show so if someone changes a control textbox for example it should be fine. In more general situations it may fail.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  9. #9
    VBAX Regular
    Joined
    Nov 2012
    Location
    Alaska
    Posts
    22
    Location
    so will this work if users that are taking my quiz, they enter their name on slide one then on the last slide that has the certificate has their name from slide one.

Posting Permissions

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