Consulting

Results 1 to 5 of 5

Thread: Adding text to text boxes

  1. #1
    VBAX Newbie
    Joined
    Jan 2018
    Posts
    2
    Location

    Adding text to text boxes

    Hello,

    I've never really used VBA before so this could be really simple for all I know, but I have created a on screen keyboard on powerpoint using action buttons, and would like to know how to add text to a text box when the corresponding key/action button is pressed, so pressing the "A" button puts A into the text box and so on, thanks!

  2. #2
    VBAX Tutor
    Joined
    Mar 2014
    Posts
    210
    Location
    Its a little hard doing it in Powerpoint since PPT is already setup for user to enter text into a text box. No programming needed.
    VB (B for basic) is easy. To assign a text box normally it would be as simple as: txtBox1 = "My Text"

    The hard part of the programming is text boxes may have random names. So vb doesnt know the name of the text box to assign the string,
    but the user can just type in without knowing the name of the textbox.
    I'll look into it some more.

  3. #3
    VBAX Tutor
    Joined
    Mar 2014
    Posts
    210
    Location
    a lot of work to do what PPT does without code.
    IF, the shapes are there.

    sub btnAdd_Click()
    Dim sld As Slide
    Set sld = Application.ActiveWindow.View.Slide
    
    
     vRet =inputbox( "Enter Text","Add")
     sld.Shapes(1).TextFrame.TextRange.Text = vRet
    
    
    set sld = nothing
    end sub

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Set up the "keyboard" with a letter on each and SPACE on the space bar.

    ALL of the keys should run this code.

    Sub AddText(oshp As Shape)
    Dim strKey As String
    Dim osld As Slide
    strKey = oshp.TextFrame.TextRange
    If strKey = "SPACE" Then strKey = " "
    Set osld = SlideShowWindows(1).View.Slide
    With osld.Shapes("Title 1")  'change the name
    .TextFrame.TextRange = .TextFrame.TextRange & strKey
    End With
    End Sub
    keys.pptm

    NOTE it will only work in show mode and you might have to change the name of the shape to show the text.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    VBAX Newbie
    Joined
    Jan 2018
    Posts
    2
    Location
    Managed to incorporate all that code onto my keyboard and it does the job, thanks!

Posting Permissions

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