Consulting

Results 1 to 2 of 2

Thread: Odd scenario with shape text. Not showing 2nd digit

  1. #1
    VBAX Newbie
    Joined
    Jun 2015
    Posts
    1
    Location

    Odd scenario with shape text. Not showing 2nd digit

    Hi everyone,

    I've stumbled upon some strange behavior, and I'm hoping you can help me.

    I have a rectangle Shape, with the value 0 in it. It's a scoreboard.
    When I click on it, a macro fires, and adds 1 to it's total.
    That works well... until I get to 10!

    When the box is at 9, and I click 1 more time, the score says "1 ".
    So it makes space for the 0, but the 0 doesn't appear.
    And if I continue to click on the box, it continues to add 1, except I never get to see the 2nd digit.
    This is also true for the 20's, 30's etc. So basically, it doesn't want to show the 2nd digit even though it makes a space for it.

    At first I thought the box wasn't big enough (even though it IS large enough),
    so I made the font extremely small, but the problem still occured.
    Then I made the box's value show in a MsgBox() and it would show the correct amount (10, 11, etc).

    And another odd thing I found. If I exited the slide show while the score was above 9 (so 10+),
    when I started it up again, the score would correctly show the second digit!

    Has anyone ever encountered this? Or do you have an idea what might be going wrong?

    Here's my code to increment the score by 1:
    Sub add1boys()
    ' Add 1 point to boys.
    ActivePresentation.SlideMaster.Shapes("boysScoreBox").TextFrame.TextRange.Text = CLng(ActivePresentation.SlideMaster.Shapes("boysScoreBox").TextFrame.TextRange.Text) + 1
    MsgBox ("POINTS: " + ActivePresentation.SlideMaster.Shapes("boysScoreBox").TextFrame.TextRange.Text)
    
    End Sub
    So to summarize, it's putting the correct value in the box, but it only displays the 1st digit even if both digits would fit.
    Also, when I restart the slide show with the score already above 9, it shows the 2 digits correctly.

    Thanks!
    - Andrew

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Not exactly what I see in 2010 but try this (and yes it is witchcraft)

    Sub add1boys()
         ' Add 1 point to boys.
         Dim oshp As Shape
         Set oshp = ActivePresentation.SlideMaster.Shapes("boysScoreBox")
        oshp.TextFrame.TextRange.Text = oshp.TextFrame.TextRange.Text + 1
        oshp.Left = oshp.Left + 1
        oshp.Left = oshp.Left - 1
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Tags for this Thread

Posting Permissions

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