Animated Scrolling Text

  • Is there a way in Vba to created animated or automatic scrolling text? I want to have a form with animated text showing credits of a addin? Is it possible to do this?

  • Re: Animated Scrolling Text

    Try this *NEW* method.

    It uses a listbox instead of a textbox and simple scrolls the information, by removing lines, like at the end of a movie.

    [vba]Option Explicit

    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Private m_blnUnload As Boolean
    Private m_blnCreditsRolling As Boolean
    Private Sub CommandButton1_Click()

    If m_blnCreditsRolling Then
    m_blnUnload = True
    Unload Me
    End If

    End Sub
    Private Sub UserForm_Activate()

    Dim lngSpeed As Long

    m_blnCreditsRolling = True
    lngSpeed = 150
    Do While ListBox1.ListCount > 0
    ListBox1.RemoveItem 0
    If m_blnUnload Then Exit Do
    Sleep lngSpeed
    m_blnCreditsRolling = False
    If m_blnUnload Then CommandButton1_Click

    End Sub
    Private Sub UserForm_Initialize()

    Dim lngIndex As Long

    For lngIndex = 1 To 30
    ListBox1.AddItem "Line of credit " & lngIndex

    For lngIndex = 1 To 30
    ListBox1.AddItem ""

    End Sub[/vba]
    The API is just a system function to delay the loop. Used to get finer control over the amount of time paused. The value is in milliseconds.

  • Re: Animated Scrolling Text

    Alright, Thanks. Got a couple questions though

    1) Is there a special way to make the text scroll through multiple times? Or is it just a sample for loop around the whlie loop in the activate sub?

    2) I tried to modify this to pull string values from an array (each loop pulling one element from the array ) to show, but I alway get an error message on the start up of the form. Could using an array cause this problem?

    For example changing


    That is what I had to cause the error. Any idea what i'm doing wrong?

  • Re: Animated Scrolling Text

    You need to add another loop for multiple rolls of the same credits.

    And use LBound and UBound to get arrays size

    This revision simply moves the top row of the list box to the bottom.