加载时Excel用户窗体的动画圆点 [英] Excel Userform animated dots on loading

查看:59
本文介绍了加载时Excel用户窗体的动画圆点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Internet上有很多教程.但是我找不到合适的东西.有什么方法可以在加载时制作动画点吗?

There are a lot of tutorials in the Internet. However I was not able to find anything suitable. Is there any way to make animated dots on loading?

这个想法是在用户窗体上循环制作一个动画点 ... ,这样它们就会一个接一个地出现,然后在一定数量的点之后重新开始.

The idea is to make a loop of animated dots ..... on userform so they would appear one after another and then would start over after some amount of dots.

所以我在Label1上输入了一个点,并在一定的时间标准后将其向左移动了?

So I input a dot to Label1 and move it to left after certain time criteria?

我当前的UserForm代码:

My current code for UserForm:

    Private Sub UserForm_Initialize()
HideTitleBar.HideTitleBar Me
    Call loadingdots
End Sub

Private Sub Workbook_Open()的代码:

Loading.Show (vbModeless)

Dim RngCom As Range
Dim RngTurb As Range
Dim RngGen As Range

Application.Wait (Now + TimeValue("00:00:06"))

ThisWorkbook.Worksheets("MAIN").ScrollArea = "$A$1:$BL$45"
    Application.DisplayFormulaBar = False
    ActiveWindow.DisplayHeadings = False
    ActiveWindow.DisplayGridlines = False
  etc...
  Unload Loading
'Application.ScreenUpdating = True
  End Sub

推荐答案

最优雅的解决方案可能是

The most elegant solution would likely to be the OnTime method.

在UF内放置一个标签,然后删除标题.接下来,在常规模块(而不是UF的模块)中,放置以下子例程:

Place a label inside your UF and remove the caption. Next, in a regular module (so not that of the UF), place this subroutine:

'this function ensures the self-activating sub will stop if the UF has been closed
Public Function IsLoaded(form As String) As Boolean
Dim frm As Object
For Each frm In VBA.UserForms
    If frm.Name = form Then
        IsLoaded = True
        Exit Function
    End If
Next frm
IsLoaded = False
End Function


Public Sub loadingdots()

If IsLoaded("UserForm1") = True Then
    If Len(UserForm1.Label1.Caption = 4) Then
        UserForm1.Label1.Caption = "."
    Else
        UserForm1.Label1.Caption = UserForm1.Label1.Caption & "."
    End If
    Application.OnTime Now + TimeValue("00:00:01"), "loadingdots"
End If

End Sub

接下来,当UF初始化时,调用自激活子

Next, call the self-activating sub when the UF gets initialised

Private Sub UserForm_Initialize()
    Call loadingdots
End Sub

不要忘记将对UF的引用更改为正确的名称.

Do not forget to change the references to the UF to the right name.

这篇关于加载时Excel用户窗体的动画圆点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆