使用excel vba卸载后,保持先前的用户窗体保持打开状态

时间:2022-11-19 22:02:19

I try using the Unload.me function to close the userform. Now i have 2 userform, when close one of the userform,automatically 2nd userform will close together. I want try to remain the previous userform open. Please help and thanks.

我尝试使用Unload.me函数关闭userform。现在我有2个userform,当关闭其中一个userform时,自动第二个userform会一起关闭。我想尝试保持以前的用户窗体打开。请帮助和谢谢。

Unload.Me

Regards, YY

2 个解决方案

#1


0  

A quick workaround, try to specify the exact form you are unloading.

快速解决方法,尝试指定要卸载的确切表单。

i.e. use Unload UserForm2

即使用Unload UserForm2

If that doesn't help, check if the forms are modal forms. If not, set them to modal.

如果这没有帮助,请检查表单是否为模态表单。如果没有,请将它们设置为模态。

#2


0  

I tried adding a subsequent instruction in the same sub procedure that called/showed Userform2 (thinking that it might not close Userform1 until it finished the rest of the code after Userform2.show). Instructions like assigning a random value to a random variable did not work, but making a message box pop up did work. For example in the sub procedure calling userform2 you might try:

我尝试在调用/显示Userform2的相同子过程中添加后续指令(认为它可能不会关闭Userform1,直到它完成Userform2.show之后的其余代码)。将随机值分配给随机变量的指令不起作用,但弹出消息框确实有效。例如,在调用userform2的子过程中,您可以尝试:

Userform2.show

Msgbox("Userform2 has already closed. Close this message box to see Userform1.")

Msgbox(“Userform2已经关闭。请关闭此消息框以查看Userform1。”)

This seems despotic to me too, but it worked.

这对我来说似乎是专制的,但它确实奏效了。

#1


0  

A quick workaround, try to specify the exact form you are unloading.

快速解决方法,尝试指定要卸载的确切表单。

i.e. use Unload UserForm2

即使用Unload UserForm2

If that doesn't help, check if the forms are modal forms. If not, set them to modal.

如果这没有帮助,请检查表单是否为模态表单。如果没有,请将它们设置为模态。

#2


0  

I tried adding a subsequent instruction in the same sub procedure that called/showed Userform2 (thinking that it might not close Userform1 until it finished the rest of the code after Userform2.show). Instructions like assigning a random value to a random variable did not work, but making a message box pop up did work. For example in the sub procedure calling userform2 you might try:

我尝试在调用/显示Userform2的相同子过程中添加后续指令(认为它可能不会关闭Userform1,直到它完成Userform2.show之后的其余代码)。将随机值分配给随机变量的指令不起作用,但弹出消息框确实有效。例如,在调用userform2的子过程中,您可以尝试:

Userform2.show

Msgbox("Userform2 has already closed. Close this message box to see Userform1.")

Msgbox(“Userform2已经关闭。请关闭此消息框以查看Userform1。”)

This seems despotic to me too, but it worked.

这对我来说似乎是专制的,但它确实奏效了。