My goal is to increase the font size of a textbox in Excel using VBA. While that's easy, what makes this problem a bit more interesting is that I need a smooth transition from font size x to font size y--an animation.
I am currently using the following code:
Option Explicit
Sub AnimateHit()
Dim i As Integer
For i = 1 To 25
ActiveSheet.Shapes.Range(Array("textEnemyHit")).Select
Selection.ShapeRange.TextFrame2.TextRange.Font.Size = i * 10
'Waits for 50ms
Call DelayMs(550)
Application.ScreenUpdating = True
Next
End Sub
'Code from http://stackoverflow.com/questions/18602979/how-to-give-a-time-delay-of-less-than-one-second-in-excel-vba
Private Sub DelayMs(ms As Long)
Debug.Print TimeValue(Now)
Application.Wait (Now + (ms * 0.00000001))
Debug.Print TimeValue(Now)
End Sub
This code works if the delay is 600ms or more. However, under 600ms, the code does not work. There is a jump from the minimum font size to the maximum without a smooth transition.
Any ideas on how I can achieve a smooth transition at a faster frame rate?
Thanks!