New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

"Unload Me" in 2010 Excel throwing Error

Macros, VBA, Excel Automation, etc.

"Unload Me" in 2010 Excel throwing Error

Postby jpk0920 » Mon Jan 16, 2012 2:08 am

Hello,

"Unload Me" Showing error in 2010 VBA. can someone get alternative for "Unload Me"...?
in 2007 VBA "Unload Me" Is working fine.
for temp I'm Using "Me.Hide" Insteadof "Unload Me". Please help.
  • 0

jpk0920
Rookie
 
Posts: 4
Joined: Dec 14, 2011
Reputation: 0

Re: "Unload Me" in 2010 Excel throwing Error

Postby Sisyphus » Mon Jan 16, 2012 10:04 am

Hi,
Have you tried both?
Code: Select all
Me.Hide
Unload Me
  • 0

Have a great day! :D

Sisyphus
I do this for "honour and country" - much less of the latter, actually.
If I helped you, award points, plenty of them.
If I bored you, deduct points for being too long-winded. (I know, :lol)
Sisyphus
Former Moderator
 
Posts: 4454
Joined: Dec 7, 2011
Location: Shanghai
Reputation: 203
Excel Version: 2010

Re: "Unload Me" in 2010 Excel throwing Error

Postby jpk0920 » Mon Jan 16, 2012 11:05 pm

"Unload Me" i'm getting error. so i'm using "Me.Hide". "Me.Hide" working fine without any errors...

My question is is there any alternative for "Unload Me"...?
and
Why "Unload Me" showing error in 2010 VBA...?

Can you please give me a clear idea about this....
  • 0

jpk0920
Rookie
 
Posts: 4
Joined: Dec 14, 2011
Reputation: 0

Re: "Unload Me" in 2010 Excel throwing Error

Postby Sisyphus » Tue Jan 17, 2012 12:41 am

Hi,
There are four steps to operating a form which you may want to keep an eye on: Load, Show, Hide and Unload.
On Load you load the form into memory but don't show it.
On Show the form becomes visible. You can't show a form that isn't loaded!
On Hide the form becomes invisible. If the form is modal the code will stop until you hide it.
On Unload the form is removed from memory. Obviously, you can't unload a form while it is showing, and be it only for the reason that you can't execute any code while it is still showing (except for code to operate the form EXCEPT to unload it).

Excel has grouped the Load action into the Show action, presuming that you want to load it since you expressed your wish to look at it. Quite possibly, Excel has done the same for the Unload event, presuming that you don't need to see it any more if you decide to unload it. For whatever reason, I suspect, Excel 2010 may not ahve inherited this presumptuousness and may insist that you hide the form before you can unload it.

There are many ways to load, show, hide and unload a form. They don't all function the same way and it is quite likely that some one will tell me it has always been this way or that and there is nothing new in Excel 2010 in this regard. For you, that kind of squabble doesn't matter because your problem is in that your form behaves differently from what you are used to. If you hide the form instead of unloading it you will not have a virgin form when you show it next. Data may have been retained in it and the initialize event won't fire. If you never unload it it will be unloaded when you close the application.

I hope that helps.
  • 0

Have a great day! :D

Sisyphus
I do this for "honour and country" - much less of the latter, actually.
If I helped you, award points, plenty of them.
If I bored you, deduct points for being too long-winded. (I know, :lol)
Sisyphus
Former Moderator
 
Posts: 4454
Joined: Dec 7, 2011
Location: Shanghai
Reputation: 203
Excel Version: 2010


Return to Macros and VBA Questions

Who is online

Users browsing this forum: No registered users and 252 guests