ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   closing a userform (https://www.excelbanter.com/excel-programming/308478-closing-userform.html)

mangesh_yadav[_50_]

closing a userform
 
I have a case where my userform could either be open or closed. How do
find in which state it is. For example, if the userform is closed and
try to close it, it is first initialised and then closed, which I don
want to do.

- Manges

--
Message posted from http://www.ExcelForum.com


GJones

closing a userform
 
Hi Mangesh;

You can create a seperate sub that includes an error
handling event. Call the form with either load or show
and then you'll know it is open. If you want it closed
then use unload and if you want it open then leave it as
show.

Thanks,

Greg
-----Original Message-----
I have a case where my userform could either be open or

closed. How do I
find in which state it is. For example, if the userform

is closed and I
try to close it, it is first initialised and then closed,

which I dont
want to do.

- Mangesh


---
Message posted from http://www.ExcelForum.com/

.


mangesh_yadav[_55_]

closing a userform
 
First of all, thanks for the reply. Yes, but the problem is that when
want to close it, and its already closed, then I don't want to open i
first and then close it. Currently, thats how I am handling it.

- Manges

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

closing a userform
 
If it is loaded, then it will be in the userforms collection

for each frm in Userforms
if frm.name = "MyUserform" then
unload frm
end if
Next

If you reference a userform and it is not loaded, then it is immediately
loaded (as you have observed/stated). This should avoid that.

--
Regards,
Tom Ogilvy

"mangesh_yadav " wrote in
message ...
First of all, thanks for the reply. Yes, but the problem is that when I
want to close it, and its already closed, then I don't want to open it
first and then close it. Currently, thats how I am handling it.

- Mangesh


---
Message posted from http://www.ExcelForum.com/




Tom Ogilvy

closing a userform
 
also, if you only have one form, you can look at

Userforms.count

as an indicator as well.

--
Regards,
Tom Ogilvy

"mangesh_yadav " wrote in
message ...
First of all, thanks for the reply. Yes, but the problem is that when I
want to close it, and its already closed, then I don't want to open it
first and then close it. Currently, thats how I am handling it.

- Mangesh


---
Message posted from http://www.ExcelForum.com/




mangesh_yadav[_57_]

closing a userform
 
Thanks Tom, this is what I wanted. It works nicely.

- Manges

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 02:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com