animated text in a userform?

R

Robert Crandal

I was thinking about placing a long sentence into a label
on a userform. Since the text is really long, and my userform
will be really short (lengthwise), would it be possible to make
the text continuously animated?? I mean, I would like
my text to constantly scroll and wrap around, kinda like
those stock ticker things.

Would the animation need to rely on some sort of timer which
instructs the userform to constantly update itself??

thank you!
 
T

Trevithick

I don't know of any tool to do what you are wanting to do, but a thought
comes to mind.

Try using a string function and some additional code so that you constantly
remove the first character of your string and concatenate it to the end, and
then update your forms' label. The possible problem is a blinking userform
that would drive you or your users crazy.
 
R

Rick Rothstein

I agree with Mark... this will drive your users crazy and it will be hard to
read. What about assigning the long text to the ControlTipText property of
the Label? That way, unless the text is humungously long, it will be be
displayed in its entirety when the user hovers the mouse over the control.
 
R

Robert Crandal

Is the ControlTipText thing sort of like a floating text box
kinda similar to the comment-box that you can install in Excel
cells?? This might be what I'm looking for.

BTW, if another application is in the foreground, and Excel
is behind/underneath it (but partially visible), AND if I hover
the mouse pointer over my userform (which is in the background),
will the ControlTipText still appear??? (I hope that question
isnt too confusing, hehe!)

Thanks so much Rick!
 
R

Robert Crandal

I played with this ControlTipText and it appears that it only becomes
visible when when both Excel and my Userform are in the foreground.
Too bad!

We dont have much space on our monitors, so I was looking for some
way to have my text become visible in front of all the other applications we
got running. Hmmm, what to do, what to do?
 
R

Rick Rothstein

See inline comments...
Is the ControlTipText thing sort of like a floating text box
kinda similar to the comment-box that you can install in Excel
cells?? This might be what I'm looking for.

Yes, but unlike the Comment Box which activates immediately, there is a
slight delay before the ControlTipText displays.
BTW, if another application is in the foreground, and Excel
is behind/underneath it (but partially visible), AND if I hover
the mouse pointer over my userform (which is in the background),
will the ControlTipText still appear??? (I hope that question
isnt too confusing, hehe!)

No, the ControlTipText will only activate if the UserForm has focus (this is
pretty much standard Windows functionality).

--
Rick (MVP - Excel)

 
T

Trevithick

I agree with Rick and have used his technique in the past. Assigning the
long string to the ControlTipText property is an easy and clean way to still
make your message available. To me, a clean interface is critical for end
users.

However, having said that, I thought I recalled John Walkenbach having an
example in his Excel 2007 Power Programming with vba. I was right, but tried
unsuccessfully for a couple of hours to cobble something together that would
work using the method I mentioned above.

I finally broke down and retrieved from my library of Walkenbach books the
answer. I was right in remembering an example. I finally modified my close
but no cigar method and used insights from Walkenbach's example and got it to
"work". I was unsuccessful even after getting it to scroll, to control the
speed of the scrolling. It is unreadable because of the speed that it
refreshes the label. And, it also required a control on the UserForm to
initiate and stop the scrolling. I could not discover a way to cause it to
scroll without it. Perhaps, and I didn't try it, use a mouseover event for
the initiation.

All the code resides in the UserForm, and follows:

Option Explicit

Dim myString As String
Dim myStringLen As Integer
Dim myLabel As String
Dim myLabelLeft As String
Dim myLabelRight As String
Dim myCaption As String
Dim myCaptionLeft As String
Dim myCaptionRight As String
Dim x As Integer
Dim myInterval As Integer
Dim Stopped As Boolean

Private Sub cmdStartStop_Click()

myString = "Let me see if I can think of some long string to scroll. "
myStringLen = Len(myString)
myLabel = myString
myCaption = myString
myInterval = 7

If cmdStartStop.Caption = "Start" Then
cmdStartStop.Caption = "Stop"

Stopped = False

Do Until Stopped
For x = 1 To myStringLen

'Display controls
lblScrollText = myLabel
txtX = x
txtLabelLength = myStringLen
frmScrollText.Caption = myCaption

'Change myLabel
myLabelLeft = Left(myLabel, myInterval)
myLabelRight = Right(myLabel, myStringLen - myInterval)
myLabel = myLabelRight & myLabelLeft

'Change myCaption
myCaptionLeft = Left(myCaption, myStringLen - myInterval)
myCaptionRight = Right(myCaption, myInterval)
myCaption = myCaptionRight & myCaptionLeft

DoEvents 'Causes the animation
Next
Loop

Else
Stopped = True
cmdStartStop.Caption = "Start"

End If

End Sub
--
Mark Trevithick


Rick Rothstein said:
See inline comments...
Is the ControlTipText thing sort of like a floating text box
kinda similar to the comment-box that you can install in Excel
cells?? This might be what I'm looking for.

Yes, but unlike the Comment Box which activates immediately, there is a
slight delay before the ControlTipText displays.
BTW, if another application is in the foreground, and Excel
is behind/underneath it (but partially visible), AND if I hover
the mouse pointer over my userform (which is in the background),
will the ControlTipText still appear??? (I hope that question
isnt too confusing, hehe!)

No, the ControlTipText will only activate if the UserForm has focus (this is
pretty much standard Windows functionality).
 
A

Andy Pope

Hi,

If you really, really want to do it try using this variation of a marquee.
http://www.ozgrid.com/forum/showthread.php?t=41046&highlight=marquee

Userform with additional Toolbox control. MS Web browser.

userform code that will, when clicked, display the contents of A1 on active
sheet.
Private Sub UserForm_Click()

Dim intUnit As Integer
Dim strTemp As String

strTemp = "<html><head><script language=""javascript"">function
noScroll(){document.body.scroll=""no"";}" & _
"</script></head><body onload=javascript:noScroll();
topmargin=""0"" leftmargin=""0"">" & _
"<marquee width=""198"" height=""22"">" & _
Range("A1").Value & _
"</marquee></body></html>"
intUnit = FreeFile
Open ThisWorkbook.Path & "\zzxqvk.htm" For Output As intUnit
Print #intUnit, strTemp
Close intUnit
Me.WebBrowser1.Navigate2 ThisWorkbook.Path & "\zzxqvk.htm"
Me.WebBrowser1.Visible = True

End Sub

Cheers
Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top