none
[PPT: VBA] Display TextBox Value from Slide 1 to TextBox in Slide2 RRS feed

  • Question

  • Hi all! 

    I am new to VBA and have one question.

    I have a textboxes in slide 1 and slide 2. I want to display the value which is typed in slide 1 textbox to the textbox in slide 2. I tried keying in this but it couldn't work.. 

    Private Sub TextBox1_Change()
    Slide1.TextBox1.Value = Slide2.TextBox1.Value
    End Sub

    Thanks for your help!

    Friday, November 9, 2012 4:52 PM

Answers

  • Hi jrc_03,

    Thanks for posting in the MSDN Forum.

    Please try following snippet:

    Option Explicit
    
    Private Sub TextBox1_Change()
        Dim ppApp As Application
        Dim ppP As Presentation
        Dim ppS As Slide
        Dim ppSps As Shape
        Dim ppT As TextBox
    
        Set ppApp = Application
        Set ppP = ppApp.ActivePresentation
        Set ppS = ppP.Slides("Slide2")
        Set ppSps = ppS.Shapes(1)
        Set ppT = ppSps.OLEFormat.Object
        ppT.Text = TextBox1.Text
        
        Set ppSps = Nothing
        Set ppS = Nothing
        Set ppP = Nothing
        Set ppApp = Nothing
    End Sub

    I hope it can help you.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, November 12, 2012 5:54 AM
    Moderator