运行代码,一旦加载完成插件。

huangapple go评论84阅读模式
英文:

Run code once add-ins have finished loading

问题

我在workbook_open过程中有一段代码。
在这段代码的开头,一个用户窗体(加载屏幕)启动,同时代码的其余部分运行以隐藏/显示适用于各个用户的工作表。

用户窗体在代码结束时关闭,然而,这意味着它在加载插件之前关闭。

是否有一种方法可以编写代码:
一旦插件加载完毕,就关闭用户窗体?

我尝试了Wait函数,但这并不起作用,它只是延迟了用户窗体的关闭,因此也延迟了插件的加载。

英文:

I have code under workbook_open procedure.
At the beginning of this code a userform (loading screen) initiates whilst the remainder of the code runs to hide/unhide sheets for the respective user.

The userform closes at the end of this code however, this means that it closes before addins have loaded.

Is there a way for me to code:
Once addins have loaded, close userform?

I attempted the Wait function however this doesn't work, this just delays the userform closing and therefore delays the addins being loaded.

答案1

得分: 0

将当前位于Workbook_Open中的代码移动到一个普通模块中的单独的"ContinueOpen"子例程中。然后从Workbook_Open中调用这个新例程,使用Application.OnTime:

Private Sub Workbook_Open()
    Application.OnTime Now, "'" & ThisWorkbook.FullName & "'!ContinueOpen"
End Sub
英文:

Move your code currently in Workbook_Open to a separate "ContinueOpen" subroutine in a normal module. Then call this new routine from Workbook_Open, using Application.OnTime:

Private Sub Workbook_Open()
    Application.OnTime Now, "'" & ThisWorkbook.FullName & "'!ContinueOpen"
End Sub

huangapple
  • 本文由 发表于 2023年8月9日 18:27:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76866856.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定