PDA

View Full Version : Odd scenario with shape text. Not showing 2nd digit



andygb4
06-10-2015, 07:48 AM
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

John Wilson
06-10-2015, 09:14 AM
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