【发布时间】:2018-04-02 14:39:00
【问题描述】:
我正在 Excel 2013 中创建选取框文本。由于 Microsoft Web 浏览器控件在 Excel 2013 和 2016 中不起作用,因此我使用了以下 VBA 代码:
Sub DoMarquee()
Dim sMarquee As String
Dim iWidth As Integer
Dim iPosition As Integer
Dim rCell As Range
Dim iCurPos As Integer
'Set the message to be displayed in this cell
sMarquee = "This is a scrolling Marquee."
'Set the cell width (how many characters you want displayed at once
iWidth = 10
'Which cell are we doing this in?
Set rCell = Sheet1.Range("M2")
'determine where we are now with the message. InStr will return the position
' of the first character where the current cell value is in the marquee message
iCurPos = InStr(1, sMarquee, rCell.Value)
'If we are position 0, then there is no message, so start over
' otherwise, bump the message to the next characterusing mid
If iCurPos = 0 Then
'Start it over
rCell.Value = Mid(sMarquee, 1, iWidth) Else
'bump it
rCell.Value = Mid(sMarquee, iCurPos + 1, iWidth)
End If
'Set excel up to run this thing again in a second or two or whatever
Application.OnTime Now + TimeValue("00:00:01"), "DoMarquee"
End Sub
在excel中每秒都在反映,有没有办法以毫秒为单位进行反映,以便它可以显示一些流畅的运行。更多的问题是,它只有在完全滚动后才会再次启动。有没有办法让它在等待整个文本滚动的情况下连续滚动。
【问题讨论】:
标签: vba excel smooth-scrolling marquee