Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default Userform in Before close event of workbook

Hi,

I am using an Userform in the Before close event of ThisWorkbook to
elicit a response from the user. The userform has 3 option buttons.
The userform has a command button on clicking of which processing is
done depending on the option button chosen. I want the control to
return from the Userform to the Before close event so that the rest of
the code in the before close event is then run.

How to do this?

Thanks in advance for the help.

Regards,
Raj
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Userform in Before close event of workbook

Hi Raj

Simple demo. ThisWorkbook module:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim UF As UserForm1
Set UF = New UserForm1
UF.Show
Select Case UF.MyValue
Case 1
MsgBox "One"
Case 2
MsgBox "two. Staying open"
Cancel = True
Case Else
End Select
Unload UF
End Sub

Userform1 module (with CommandButton1 and 2):

Public MyValue As Long

Private Sub CommandButton1_Click()
MyValue = 1
Me.Hide
End Sub

Private Sub CommandButton2_Click()
MyValue = 2
Me.Hide
End Sub

HTH. Best wishes Harald



"Raj" wrote in message
...
Hi,

I am using an Userform in the Before close event of ThisWorkbook to
elicit a response from the user. The userform has 3 option buttons.
The userform has a command button on clicking of which processing is
done depending on the option button chosen. I want the control to
return from the Userform to the Before close event so that the rest of
the code in the before close event is then run.

How to do this?

Thanks in advance for the help.

Regards,
Raj


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default Userform in Before close event of workbook

On Jun 30, 9:42*pm, Raj wrote:
Hi,

I am using an Userform in the Before close event of ThisWorkbook to
elicit a response from the user. The userform has 3 option buttons.
The userform has a command button on clicking of which processing is
done depending on the option button chosen. I want the control to
return from the Userform to the Before close event so that the rest of
the code in the before close event is then run.

How to do this?

Thanks in advance for the help.

Regards,
Raj


Hi,

I added an Unload Me in the Command button click code and the control
returned to the Before close event.

Regards,
Raj
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Userform in Before close event of workbook

Call your userform from the BeforeClose Event like so.

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Call UserForm1

'the rest of your code

End Sub

I assume the processing code you are talking about is contained in the
CommandButton1_Click Event. If so, when the user clicks the command button
make sure the Userform is Unloaded (Me Unload) and the Before Close Event
will continue.

I think this is what you are saying.
--
Cheers,
Ryan


"Raj" wrote:

Hi,

I am using an Userform in the Before close event of ThisWorkbook to
elicit a response from the user. The userform has 3 option buttons.
The userform has a command button on clicking of which processing is
done depending on the option button chosen. I want the control to
return from the Userform to the Before close event so that the rest of
the code in the before close event is then run.

How to do this?

Thanks in advance for the help.

Regards,
Raj

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Userform in Before close event of workbook

I added an Unload Me in the Command button click code and the control
returned to the Before close event.


Now I'm really curious. Why the Unload Me?

Best wishes Harald



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
Workbook close event kpriyac[_2_] Excel Programming 3 August 18th 06 07:20 PM
why does userform close after programming worksheet event with CreateEventProc or AddFromString tr00per Excel Programming 3 February 4th 06 10:09 PM
Excel WorkBook Close Event Xcelion Excel Programming 2 January 27th 06 03:29 PM
Close UserForm despite Exit Event Carim[_3_] Excel Programming 4 May 17th 05 05:39 AM
Workbook Close Event Stefano Condotta Excel Programming 1 June 16th 04 10:44 PM


All times are GMT +1. The time now is 04:07 AM.

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

About Us

"It's about Microsoft Excel"