Share via

VBA Textbox Powerpoint

Anonymous
2019-08-01T20:28:00+00:00

I am able to enter characters in textbox1 on Slide 1, but how can I enter characters separately in textbox2 on the same slide (slide1) without altering textbox1?

The following code works for textbox1:

Sub SetCurrentText(sText)

' Sets the current text

' Modified to work with a VBA shape called TextBox1

sCurrentText = sText

' But could just as well set the text in a text box or text control

' See examples above

ActivePresentation.Slides(1).Shapes("TextBox1").OLEFormat.Object.Text = sText

End Sub

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. John Korchok 232.8K Reputation points Volunteer Moderator
    2019-08-02T13:37:20+00:00

    Sorry, I don't understand this sentence:

    "there a code for both textbox1 and textbox2 on slide1"

    Please describe the issue in more detail. We don't know how your presentation is constructed or what you're trying to accomplish..

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2019-08-01T22:28:04+00:00

    On slide1, 

    ActivePresentation.Slides(1).Shapes("TextBox1").OLEFormat.Object.Text = sText works for textbox1

    ActivePresentation.Slides(1).Shapes("TextBox2").OLEFormat.Object.Text = sText works for textbox2 

    but is there a code for both textbox1 and textbox2 on slide1.

    Was this answer helpful?

    0 comments No comments
  3. John Korchok 232.8K Reputation points Volunteer Moderator
    2019-08-01T21:56:15+00:00

    Just change the name to the name of the second text box. Here's a little better syntax for that:

    ActivePresentation.Slides(1).Shapes("TextBox 4").TextFrame2.TextRange.Text = sText

    Was this answer helpful?

    0 comments No comments