none
PowerPoint 2007 VBA - Macro to display Text Captured from Text Box on previous slide

    Question

  • I have a slide (slide index 3), with 1 VBA Text Boxe to capture name then user clicks Next which runs this Macro:

    Sub ExtractData()
    pName = ActivePresentation.Slides(3).Shapes("TextBox1").TextFrame.TextRange.Text

    ActivePresentation.SlideShowWindow.View.Next
    'ActivePresentation.Slides(4).Shapes("TextBox1").TextFrame.TextRange.Text = pName

    End Sub

    On the next slide(Slide Index 4), I have a blank textbox with no text entered by default.  The objective of the Macro is to use the Name captured in Slide 3, and update the textbox (Text Frame in PP speak) to show that name.

    It does not work, any ideas?

    Friday, February 03, 2012 11:19 AM

Answers

  • I imagine it is stopping on this line:

    pName = ActivePresentation.Slides(3).Shapes("TextBox1").TextFrame.TextRange.Text
    


    The TextBox is an ActiveX control. Text entered into the control is available in the control's Value property.

    If your ExtractData subroutine is on the slide instead of a module, you can write:

    Me.TextBox1.Value

    If your subroutine is in a module, you can write:

    Slide3.TextBox1.Value



    • Marked as answer by Bruce Song Thursday, February 23, 2012 9:16 AM
    Friday, February 03, 2012 3:34 PM

All replies

  • I imagine it is stopping on this line:

    pName = ActivePresentation.Slides(3).Shapes("TextBox1").TextFrame.TextRange.Text
    


    The TextBox is an ActiveX control. Text entered into the control is available in the control's Value property.

    If your ExtractData subroutine is on the slide instead of a module, you can write:

    Me.TextBox1.Value

    If your subroutine is in a module, you can write:

    Slide3.TextBox1.Value



    • Marked as answer by Bruce Song Thursday, February 23, 2012 9:16 AM
    Friday, February 03, 2012 3:34 PM
  • Hello, I have this same question - I want a VBA text box to carry the same information to another VBA text box on the next slide. Could you please supply more information about your answer?

    If put into a module, is this what Viper19's code would look like modified per your comments?

    Sub ExtractData()
    pName = Slide3.Textbox1.Value

    ActivePresentation.SlideShowWindow.View.Next
    ActivePresentation.Slides(4).Shapes("TextBox1").TextFrame.TextRange.Text = pName

    End Sub

    I have very rudimentary knowledge of VB, so the more information you can supply the better.

    Thank you,

    Ryan

    Wednesday, June 06, 2012 2:57 PM
  • Hi Ryan,

    If you are reading from or writing to an ActiveX TextBox control, you can use the Value property of control.

    If you are reading from or writing to a Shape with text (TextFrame), you can use the Shape's TextFrame.TextRange.Text property.

    So, if you are using ActiveX TextBoxes on both slides you could write:

    Slide4.TextBox1.Value = Slide3.TextBox1.Value

    You could add this to the On Change event of the TextBox on Slide 3.

    Right Click the TextBox on Slide 3. From the Context Menu select View Code.

    The Visual Basic Editor will open with begining and ending statements for the On Change Event.

    Enter the statement above (making any changes as required to specify your Slide Names and TextBox Names).

    The Value of TextBox1 on Slide 4 will change when you change the one on Slide 3 (during presentation).

    I hope that helps.

    • Proposed as answer by RFechner Wednesday, June 06, 2012 6:32 PM
    Wednesday, June 06, 2012 3:47 PM
  • William,

    Thank you for the quick response! This solution almost seems to work - However, during the presentation it won't actively update, but if I start typing in the  text box on the next slide, it will then paste the value from the previous slide. Any ideas?

    Thank you,

    Ryan

    Wednesday, June 06, 2012 4:27 PM
  • I sounds like the code is running with the On Change event of TextBox on the second slide.

    It can happen easily when there are lots of objects named the same thing (ie TextBox1).

    Have another look and see if you have the On Change event for the first TextBox1.

    Let me know.

    Wednesday, June 06, 2012 4:39 PM
  • Excellent! Thank you!! I scoured the internet for many many hours trying to find this solution, it was much easier than I was imagining.

    Thank you again,

    Ryan

    Wednesday, June 06, 2012 5:58 PM