Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default 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/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default closing a userform

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

- Manges

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform won't show after closing another file Gerry O Excel Discussion (Misc queries) 8 September 7th 07 03:51 PM
Vba - automaticaly closing userform ajliaks[_30_] Excel Programming 1 August 22nd 04 09:53 AM
Closing the Userform when macro is running SuperJas Excel Programming 5 December 10th 03 05:31 AM
userform titlebar and closing form D.S.[_3_] Excel Programming 6 November 29th 03 06:26 PM
Help with closing a UserForm Ron de Bruin Excel Programming 0 August 8th 03 01:52 PM


All times are GMT +1. The time now is 03:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"