none
VBA Question (PowerPoint) RRS feed

  • Question

  • I have some code that allows me to send two digit numbers to a shape on a PowerPoint slide. (See below.)  The number "11" does not work probably because both digits are the same.  Help!

    Sub TextBox1_Change()

    If Len(Me.TextBox1.Text) = 2 Then
    Select Case UCase(Me.TextBox1.Text)
    Case "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"
    strIn = UCase(Me.TextBox1.Text)
    Set osld = ActivePresentation.SlideShowWindow.View.Slide
    strResult = osld.Shapes("Results").TextFrame.TextRange.Text
    If InStr(strResult, strIn) > 0 Then
    'exists
    Else
    If strResult <> "" Then
    osld.Shapes("Results").TextFrame.TextRange = strResult & vbCrLf & strIn
    Else
    osld.Shapes("Results").TextFrame.TextRange = strIn
    End If
    End If
    Case Else
    'nothing
    End Select
    Me.TextBox1.Text = ""
    End If
    End Sub


     
    Monday, May 2, 2016 11:39 PM

All replies

  • I have some code that allows me to send two digit numbers to a shape on a PowerPoint slide. (See below.)

    Questions relating to VBA should be asked here:

    Visual Basic for Applications  (VBA)

    When you post your query there, make sure that it is clear whether 'does not work' means that the Select is not being triggered, or that it is being triggered, but the result is not what you expected.

    • Proposed as answer by Albert_Zhang Tuesday, May 3, 2016 1:48 AM
    Tuesday, May 3, 2016 1:24 AM
  • I can't see why your macro is not working for 11. If it works for other numbers, definitely should work for 11.

    http://www.ambienteoffice.com.br - http://www.clarian.com.br

    Tuesday, May 3, 2016 12:36 PM
  • Thank you.  Will do.
    Tuesday, May 3, 2016 3:39 PM