Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Closing the Userform when macro is running

Hi,

I've created an add-in that, upon pressing the button, a userform appears and different macro codes execute depending on the user's command-button choice.

After the user presses a command button, the macro springs into action, and will often run for 1min or so. What I would like to do is to have that userform close after the user presses the command button and starts off the macro.

My setup is like this:

Add-in button code:

Sub ShowForm()

Myform.show

End Sub

-----------

This shows the userform. I then have code within each command button.

Thanks for your help in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Closing the Userform when macro is running

Something like:

Unload UserForm1

should do it.

--

Vasant

"SuperJas" wrote in message
...
Hi,

I've created an add-in that, upon pressing the button, a userform appears

and different macro codes execute depending on the user's command-button
choice.

After the user presses a command button, the macro springs into action,

and will often run for 1min or so. What I would like to do is to have that
userform close after the user presses the command button and starts off the
macro.

My setup is like this:

Add-in button code:

Sub ShowForm()

Myform.show

End Sub

-----------

This shows the userform. I then have code within each command button.

Thanks for your help in advance!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Closing the Userform when macro is running

Hi Vasant,

Thanks for your tip. However, I've tried it and it still doesn't unload/hide as I'd like.

I've pasted the "Unload Myform" line in the command-button code section. When I run the code via the "Step-into" method, the userform does close, but when I run it normally it doesn't...

So I'm thinking this might have something to do with the "Application.Screenupdating=False" command. However, this line is below the "Unload Myform" line, so I can't figure out what the problem is...

Thanks for your time!




----- Vasant Nanavati wrote: -----

Something like:

Unload UserForm1

should do it.

--

Vasant
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default Closing the Userform when macro is running

Jas,

You might want to try Userform1.Hide and/or DoEvents to make the form
display go away. Are you using a modeless form?

Alex J

"SuperJas" wrote in message
...
Hi Vasant,

Thanks for your tip. However, I've tried it and it still doesn't

unload/hide as I'd like.

I've pasted the "Unload Myform" line in the command-button code section.

When I run the code via the "Step-into" method, the userform does close, but
when I run it normally it doesn't...

So I'm thinking this might have something to do with the

"Application.Screenupdating=False" command. However, this line is below the
"Unload Myform" line, so I can't figure out what the problem is...

Thanks for your time!




----- Vasant Nanavati wrote: -----

Something like:

Unload UserForm1

should do it.

--

Vasant



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Closing the Userform when macro is running

If you don't want to close the form out completely you can use:

UserForm1.Hide instead of Unload UserForm1

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message ...
Something like:

Unload UserForm1

should do it.

--

Vasant

"SuperJas" wrote in message
...
Hi,

I've created an add-in that, upon pressing the button, a userform appears

and different macro codes execute depending on the user's command-button
choice.

After the user presses a command button, the macro springs into action,

and will often run for 1min or so. What I would like to do is to have that
userform close after the user presses the command button and starts off the
macro.

My setup is like this:

Add-in button code:

Sub ShowForm()

Myform.show

End Sub

-----------

This shows the userform. I then have code within each command button.

Thanks for your help in advance!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Closing the Userform when macro is running

Hi Alex,

Thanks for your tip! It turned out that the "DoEvents" command was needed to hide/close the userform.

kfarmer, thanks for your suggestion. I haven't given much thought as to whether to unload or hide the form...would the choice affect performance? For now I've chosen the hide property purely because I'm more used to that...

Thanks, Vasant, Alex, and Kfarmer for your time! =)

Jas.

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
Auto running a macro on closing Jimmy D Excel Discussion (Misc queries) 6 November 22nd 07 01:58 AM
Userform won't show after closing another file Gerry O Excel Discussion (Misc queries) 8 September 7th 07 03:51 PM
Re-show userform after closing file - code help Gerry O Excel Discussion (Misc queries) 3 September 4th 07 10:52 PM
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 05:40 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"